Questions tagged [ansible-playbook]
468 questions
0
votes
1 answer
Ansible shell passes a command without executing it
I am using ansible for the execution of a script (myScript.sh) over some nodes through the command:
- hosts: primaryNodes,!node13
vars:
mongodPath: /usr/local/mongodb
become: yes
become_user: user
tasks:
- name: starting mongod on all…

Nicholas Kou
- 1
- 2
0
votes
1 answer
Getting a fact from group not specified in role in ansible
My ansible playbook has specified which group it's for. But the role that is specified, needs to get a specific variable from another group the host is in, because the apache setup is dependent on which location group the host is in.
How can the…
0
votes
1 answer
Failing play prevents later 'localhost' play from executing
I've written the following playbook. I expect an error from the second play, but the first and third to run. What I get is the first running, the second failing, and the third is completely ignored.
If I make the second play succeed then the third…

sherbang
- 361
- 3
- 6
0
votes
1 answer
How access ansible dictionary ansible_net_interfaces sub branches
I'm trying to read information from ansible_net_interfaces, but the interface names will be different on each device. I'm having no trouble accessing most information, but when I get to ipv4, there's a sub-array, and no matter what I try, I can't…

Soop
- 121
- 1
- 5
0
votes
0 answers
ansible:manipulating 200 files quick
I have a tomcat server with 200 instances.
I have created a playbook for deploying a new server and it works fine, BUT
I have several plays that manipulate numerous files in each tomcat-instance, and the way it is going now is that the…

MSchultz
- 11
- 4
0
votes
1 answer
Ansible source of variables
I have a playbook like:
- hosts: GROUP1
remote_user: ubuntu
become: true
gather_facts: False
roles:
- role: role1
- role: role2
The in group_var
GROUP1 has php7 packages
GROUP2 has php5 packages
when I run the runbook both php5 and php7…

Francisco1844
- 260
- 2
- 8
0
votes
1 answer
How to redirect register output for failed hosts in ansible using assert or any ways
- name: Check the VolumeGroup has 5gb space
assert:
that: ansible_lvm.vgs.VG00.free_g|int >= 5
fail_msg: 'VG has no free space'
success_msg: "{{ ansible_lvm.vgs.rhel.free_g }}"
register: vg00
- name: Line in file
shell: echo -e "{{…

pugazhendhi
- 27
- 1
- 3
0
votes
1 answer
How to write a when condition when a partition exists in ansible playbook
I'm trying to write to task when /var partition exists. I used assert variable
- name: Apply patch if /var exist and > 300MB
yum:
name: '*'
state: latest
loop: "{{ ansible_mounts }}"
when: item.mount == "/var" and item.size_available >…

pugazhendhi
- 27
- 1
- 3
0
votes
1 answer
Docker enterprise installation on CIS AMI of windows 2016 server
I am trying to install the Docker enterprise edition on CIS AMI of windows 2016 server using ansible. I am using PowerShell module for this installation. The code is as below for the docker installation task.
- name: Install Docker for windows.
…

Shailesh Sutar
- 1,517
- 5
- 23
- 41
0
votes
1 answer
sudo twice become method for Ansible
I have to deal with a setup in "/etc/sudoers" that I can't change because the servers in question are managed by a different team and they don't want to change it.
I have root access only by sudoing to another account first. My account is only…

Beam Davis
- 101
- 3
0
votes
1 answer
init.d kills my mongod process due to respawning
I'm using Ansible to start the mongod service on a Centos 6.8 VM.
The task is pretty straightforward:
- name: Start mongod service
service:
state: started
name: mongod
However the service fails to start, and in /var/log/messages I…

Andrew Fielden
- 103
- 2
0
votes
1 answer
Ansible lineinfile doesn't find a particular string when state present
I would like to check if admin_token is defined in my keystone.conf file. To do so I want to use Ansible. However, even if the attribute is present in the file, the task fails.
I compared two tasks with the lineinfile module (same regex, state…

Antonin M.
- 205
- 1
- 3
- 8
0
votes
0 answers
Uploading a tree structure with an ansible-playbook
I've been messing about with templates in my ansible-playbook lately, and it does as intended now: Upload a dynamic config file, and change a few entries in it.
However, this config file is part of a small structure of static files and folders that…

Jarmund
- 535
- 2
- 6
- 17
0
votes
1 answer
How to filter shell result
We have run a playbook with shell module to retrieve data using curl command
we are able retrieve data but that data containing lot of information so would like filter that data.
can some one tell me how can i filter those data ?
0
votes
1 answer
Passing the list of values to a python script as arguments inside ansible script
I have a python script inside ansible playbook:
---
- hosts: localhost
become: yes
become_method: sudo
become_user: root
gather_facts: false
tasks:
- name: execute script
command: ./qwe.py
register: python_output
…

user576453
- 1
- 1
- 1