Questions tagged [ansible]

On-topic questions are concerned with the use of the tool itself. Installing Ansible and prerequisites, connection issues, ... are off-topic. Red Hat Ansible is a model-driven, configuration management, multi-node deployment/orchestration and remote task execution system. It uses SSH by default, so there is no special software to be installed on the nodes you manage. Ansible is written in Python but can be extended in any language.

Red Hat® Ansible® is a model-driven, configuration management, multi-node deployment/orchestration and remote task execution system. It uses SSH and Python by default, so there is no special software to be installed on the nodes you manage. Simply, it is an agentless configuration management tool. Ansible can be extended in any language, as long as the modules can process and respond with JSON.

The biggest advantage of Ansible over other configuration management technologies is, it is agent-less, i.e., no clients need to be installed, which avoids the chicken and egg problem.

The name "ansible" is taken from the science fiction concept of a machine capable of instantaneous or superluminal communication.

While only a Linux node can be used as a control machine, it remains nonetheless possible to have Windows nodes as a target into Ansible.

Ansible capabilities have gained a lot of modules to cover Infrastructure as a Service, Platform as a Service, and Service as a Service.

Ansible is also capable of interacting with a lot of network equipment like Cisco IOS, Juniper Junos or F5 Bigip.

Ansible has two major products,

  • Ansible Engine - Easily and quickly deploy IT services, applications and environments, remove barriers between IT teams by automating routine activities.

  • Ansible Tower - With Red Hat® Ansible® Tower you can centralize and control your IT infrastructure with a visual dashboard, role-based access control, job scheduling, integrated notifications and graphical inventory management. Easily embed Ansible Tower into existing tools and processes with REST API and CLI.

Relevant links:

Related tags:

23075 questions
499
votes
26 answers

How to create a directory using Ansible

How do you create a directory www at /srv on a Debian-based system using an Ansible playbook?
Gaurav Agarwal
  • 18,754
  • 29
  • 105
  • 166
293
votes
8 answers

Run command on the Ansible host

Is it possible to run commands on the Ansible controller node? My scenario is that I want to take a checkout from a git server that is hosted internally (and isn't accessible outside the company firewall). Then I want to upload the checkout…
Ross
  • 46,186
  • 39
  • 120
  • 173
290
votes
27 answers

Specify sudo password for Ansible

How do I specify a sudo password for Ansible in non-interactive way? I'm running Ansible playbook like this: $ ansible-playbook playbook.yml -i inventory.ini \ --user=username --ask-sudo-pass But I want to run it like this: $ ansible-playbook…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
286
votes
11 answers

How can I pass variable to ansible playbook in the command line?

How can one pass variable to ansible playbook in the command line? The following command didn't work: $ ansible-playbook -i '10.0.0.1,' yada-yada.yml --tags 'loaddata' django_fixtures="tile_colors" Where django_fixtures is my variable.
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
274
votes
14 answers

Safely limiting Ansible playbooks to a single machine?

I'm using Ansible for some simple user management tasks with a small group of computers. Currently, I have my playbooks set to hosts: all and my hosts file is just a single group with all machines listed: # file:…
joemaller
  • 19,579
  • 7
  • 67
  • 84
258
votes
14 answers

How to move/rename a file using an Ansible task on a remote system

How is it possible to move/rename a file/directory using an Ansible module on a remote system? I don't want to use the command/shell tasks and I don't want to copy the file from the local system to the remote system.
Christian Berendt
  • 3,416
  • 2
  • 13
  • 22
243
votes
7 answers

How to run only one task in ansible playbook?

Is there a way to only run one task in ansible playbook? For example, in roles/hadoop_primary/tasks/hadoop_master.yml. I have "start hadoop job tracker services" task. Can I just run that one task? hadoop_master.yml file: # Playbook for Hadoop…
Billz
  • 7,879
  • 7
  • 33
  • 35
240
votes
14 answers

How to ignore ansible SSH authenticity checking?

Is there a way to ignore the SSH authenticity checking made by Ansible? For example when I've just setup a new server I have to answer yes to this question: GATHERING FACTS *************************************************************** The…
Johan
  • 37,479
  • 32
  • 149
  • 237
220
votes
22 answers

Ansible: How to delete files and folders inside a directory?

The below code only deletes the first file it gets inside the web dir. I want to remove all the files and folders inside the web directory and retain the web directory. How can I do that? - name: remove web dir contents file:…
Abbas
  • 3,144
  • 2
  • 25
  • 45
204
votes
13 answers

How to check if a file exists in Ansible?

I have to check whether a file exists in /etc/. If the file exists then I have to skip the task. Here is the code I am using: - name: checking the file exists command: touch file.txt when: $(! -s /etc/file.txt)
E Dine Sh
  • 2,057
  • 2
  • 12
  • 3
204
votes
10 answers

ansible: lineinfile for several lines?

The same way there is a module lineinfile to add one line in a file, is there a way to add several lines? I do not want to use a template because you have to provide the whole file. I just want to add something to an existing file without…
Michael
  • 8,357
  • 20
  • 58
  • 86
201
votes
5 answers

What's the difference between defaults and vars in an Ansible role?

When creating a new Ansible role, the template creates both a vars and a defaults directory with an empty main.yml file. When defining my role, I can place variable definitions in either of these, and they will be available in my tasks. What's the…
nwinkler
  • 52,665
  • 21
  • 154
  • 168
194
votes
20 answers

Ansible fails with /bin/sh: 1: /usr/bin/python: not found

I'm running into an error I've never seen before. Here is the command and the error: $ ansible-playbook create_api.yml PLAY [straw] ****************************************************************** GATHERING FACTS…
jdavis
  • 1,987
  • 2
  • 10
  • 5
187
votes
5 answers

How to switch a user per task or set of tasks?

A recurring theme that's in my ansible playbooks is that I often must execute a command with sudo privileges (sudo: yes) because I'd like to do it for a certain user. Ideally I'd much rather use sudo to switch to that user and execute the commands…
rgrinberg
  • 9,638
  • 7
  • 27
  • 44
185
votes
10 answers

Where can I get a list of Ansible pre-defined variables?

I see that Ansible provide some pre-defined variables that we can use in playbooks and template files. For example, the host IP address is ansible_eth0.ipv4.address. Googleing and searching the docs I couldn't find a list of all available…
neves
  • 33,186
  • 27
  • 159
  • 192
1
2 3
99 100