Questions tagged [ansible]

Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad-hoc task execution, and configuration management.

Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad-hoc task execution, and configuration management. It manages nodes over SSH and does not require any additional remote software to be installed on them. Modules work over JSON and standard output and can be written in any programming language. The system uses YAML to express reusable descriptions of systems.

The platform was created by Michael DeHaan, the author of the provisioning server application Cobbler and co-author of the Func framework for remote administration. It is included as part of the Fedora distribution of Linux, owned by Red Hat inc., and is also available for Red Hat Enterprise Linux, CentOS and Scientific Linux via Extra Packages for Enterprise Linux (EPEL) as well as other operating systems. Ansible was commercially supported and sponsored by AnsibleWorks. Since October 2015 Ansible is owned by RedHat.

It was named by DeHaan after the fictional instantaneous hyperspace communication system featured in Orson Scott Card's Ender's Game.

1762 questions
18
votes
1 answer

Loop over Ansible variable array in Jinja2 template

when Ansible gathers facts about hosts, it for example gets all the mounts of the host: "ansible_mounts": [ { "block_available": 7800291, "block_size": 4096, "block_total": 8225358, …
ThatGuyOnTheNet
  • 193
  • 1
  • 1
  • 6
18
votes
8 answers

Ansible: Add IPs from inventory to /etc/hosts of all nodes

I am deploying a small 3 node cluster and I want to add the public IP addresses as defined in my inventory to the /etc/hosts files of all of the nodes. I am trying to use the following, but it is giving me an error: - name: Add IP address of all…
Kevin
  • 827
  • 3
  • 13
  • 23
18
votes
6 answers

Validate nginx.conf during ansible deploy

I have a single Ansible-provisioned server running a number of sites. My Ansible tasks look roughly like: - name: site nginx config template: src="nginx-site.conf.j2" dest=/etc/nginx/conf.d/{{item.name}}.conf owner=root group=root…
Erin Call
  • 291
  • 1
  • 2
  • 5
18
votes
7 answers

Ansible: Can I use vars_files when some files do not exist

That's the part: vars_files: - vars/vars.default.yml - vars/vars.yml If a file vars/vars.yml does not exist - here is an error. ERROR: file could not read: /.../vars/vars.yml How can I load additional variables from this file only if it…
Sergey
  • 714
  • 2
  • 6
  • 21
17
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
  • 2,187
  • 12
  • 36
  • 60
17
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
  • 302
  • 1
  • 2
  • 12
17
votes
1 answer

Create and mount GlusterFS volume with Ansible

I am using GlusterFS to create and mount volumes across 4 machines. Say for example, the machines are called machine1, machine2, machine3 and machine4. My peers have already been successfully probed. I have used the following command to create my…
Karim Tabet
  • 273
  • 2
  • 8
17
votes
3 answers

Creating a symlink with ansible and a list of variables

Brand new to ansible - I'm trying to symlink a bunch of files in a src directory to a destination.. Currently: file: src: /drupal/drush/{{ item.path }}.aliases.drushrc.php dest: /home/vagrant/.drush/{{ item.dest }}.aliases.drushrc.php …
williamsowen
  • 1,167
  • 3
  • 16
  • 25
17
votes
5 answers

When is it appropriate to use a configuration manager (eg Puppet / Chef / Ansible)?

At my current workplace, I look after two VMware host machines, an OpenBSD physical machine, three Debian VM's, and six Windows Server VM's (2008/2012). I'm considering implementing a configuration management tool such as Puppet or Chef. Is this…
Rhyven
  • 183
  • 8
17
votes
4 answers

How to do a git pull/push using ansible

I am trying to do a git pull/push using ansible. I am running ansible on one server and want to automate or orchestrate a git pull/push on a remote host. Now since i didn't find a mmodule to do this on ansible doc website, i decided to go the script…
grant tailor
  • 505
  • 2
  • 6
  • 13
17
votes
2 answers

How to clean up stuff from roles that aren't used any more on a server?

Suppose I have a host that is, among other things, a web server, where the related Ansible role installs nginx, performs some essential configuration in /etc/nginx, and opens up ports 80 and 443 in the firewall. At some point I want that particular…
Antonis Christofides
  • 2,598
  • 2
  • 23
  • 35
16
votes
4 answers

How do I generate and set the locale using ansible?

I am looking for an idempotent ansible role/task to ensure a certain locale (like en_US.UTF-8) is set as default. It should generate the locale (only if necessary) and set it as a default (also only if necessary). For the first part I'd register the…
mniess
  • 343
  • 1
  • 2
  • 9
16
votes
2 answers

Are Ansible handlers defined in roles ran after the entire playbook or the role?

I'm running Ansible 2.0, and I could just run this, but I could also be tricked in to believing something that isn't true by my empirical tests and I can find no documentation to tell me when handlers are supposed to be ran. If handlers aren't ran…
Peter Turner
  • 2,178
  • 9
  • 33
  • 45
16
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
  • 301
  • 1
  • 2
  • 8
16
votes
3 answers

How to check the JSON response from a uri request with Ansible?

I have an Ansible task that makes a URI request to a website to get a JSON response. I want Ansible to do something if the nested JSON variable is defined, and something else if it isn't. - name: Get JSON from the Interwebs uri:…
Neil
  • 2,425
  • 8
  • 36
  • 45