Questions tagged [ansible-playbook]

411 questions
39
votes
3 answers

Is there a way to check that a dictionary key is not defined in ansible task?

So in my code I have a task - name: cool task shell: 'touch iamnotcool.txt' when: me.cool is not defined and my vars looks like --- me: stumped: yes So when I run the task it comes back with the following error {"failed": true, "msg": "The…
Luis F Hernandez
  • 633
  • 1
  • 7
  • 9
30
votes
3 answers

How to run multiple playbooks in order with Ansible?

I'm working on several Ansible playbooks to spin up a new server instance. There are approximately 15 different playbooks I need to run in a specific order to successfully spin up a server. My initial thought was to write a shell script that…
nulltek
  • 1,171
  • 3
  • 13
  • 22
26
votes
4 answers

Ansible: Is it possible to "cat file" and export it's output to screen while playing a playbook and not as debug?

I wrote a playbook which installs and configures Google Authenticator per user. I want the last step of the playbook to cat the google_authenticator configuration file. Using the "debug" module I am able to get the data to be displayed on screen but…
Itai Ganot
  • 10,424
  • 27
  • 88
  • 143
26
votes
6 answers

Ansible: How to run one Task Host by Host?

On the play-level, we have serial: 1 to allow us to run the whole play one host at a time. But I haven't found a simple way to do this on a single task. This is especially relevant, if the task in question doesn't perform proper locking (for…
Elrond
  • 556
  • 2
  • 5
  • 16
18
votes
1 answer

The value True (type bool) in a string field was converted to u'True' (type string)

I'm trying to follow parameters/examples, yet running into following WARNING message while executing Ansible'playbook: TASK [apt (pre)] ******************************************************************************************** [WARNING]: The value…
alexus
  • 12,342
  • 27
  • 115
  • 173
17
votes
5 answers

How to destroy/delete/unset a variable value in Ansible?

Is there a way to destroy the variable in Ansible? Actually, I have a {{version}} variable being used in my all roles for respective packages. When I run multiple roles, the version value of one role is passed to another - this is due to for some…
MMA
  • 355
  • 3
  • 7
  • 16
15
votes
2 answers

Ansible conditionals - Wildcard match string

I have the following conditional in an Ansible task: when: ec2_tag_Name == 'testhost01' It works fine, however I would like to match a wildcard on the ec2_tag_Name field. So something like this when: ec2_tag_Name == 'testhost*' The goal is to…
emmdee
  • 1,935
  • 9
  • 35
  • 56
15
votes
1 answer

Why is ansible notify not working?

I'm learning ansible and wrote simple playbook, but I don't understand or what I'm doing wrong that handler not working! Please, help me. My playbook: - hosts: HA gather_facts: False tasks: - name: Installs pacemaker yum:…
akashavkin
  • 191
  • 1
  • 1
  • 7
12
votes
2 answers

Force Ansible to log off to refresh user groups

I'm setting up a server with Ansible and Docker. I'm currently learning both technologies, so please bear with me if I'm being overly stupid here. In order to run run Docker commands, the user has to be in the docker user group. So I'm doing this: -…
11
votes
3 answers

Rollback the changes in Ansible

Is there any method to rollback the changes in Ansible? Suppose my play book contains different plays like create 5 users,install 3 rpms, start the services. If I want to rollback a certain play how can I do. Is there any possibility that we can…
KKE
  • 135
  • 1
  • 2
  • 11
11
votes
1 answer

In ansible, how do I specify an exclusion set of hosts in a playbook?

With command line patterns, you can specify patterns like "all,!ntpservers" but I can't figure out how to specify this in a playbook. I'm regularly running into cases where I have to install a client on all machines except the server.
Robert Rapplean
  • 243
  • 1
  • 2
  • 11
11
votes
1 answer

What is reasonable performance for a simple Ansible playbook against ~100 hosts?

We are starting to look at Ansible to replace an old cfengine2 installation. I have a simple playbook that: copies a sudoers file copies a templated resolv.conf (fed with group_vars and host_vars data) checks a couple of services are running checks…
user53814
  • 376
  • 1
  • 9
11
votes
2 answers

Why does an `"[Errno 2] No such file or directory", "rc"` issue occur when Ansible is executed remotely?

Running: - name: get vhosts command: rabbitmqctl list_vhosts register: vhosts changed_when: false by issuing sudo ansible-playbook file.yml results in: TASK [030.sensu : get vhosts] ************************************************** fatal:…
030
  • 5,731
  • 12
  • 61
  • 107
11
votes
3 answers

ansible-playbook --limit more than one host?

For various reasons/limitations I cannot make new groups in the inventory file and need to use --limit/-l to specify the hosts. I was told to do something like: ansible-playbook -i /path/to/my/inventory/file.ini -l server.1.com server.2.com…
ConstantFun
  • 243
  • 1
  • 2
  • 8
9
votes
1 answer

Register ansible variable in multiple tasks

I'm using the following tasks in an ansible script that installs updates on various servers. These tasks are for CentOS machines: - name: Check for outstanding reboot shell: needs-restarting > /dev/null || echo Reboot required when:…
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
1
2 3
27 28