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
72
votes
12 answers

Ansible: copy a directory content to another directory

I am trying to copy the content of dist directory to nginx directory. - name: copy html file copy: src=/home/vagrant/dist/ dest=/usr/share/nginx/html/ But when I execute the playbook it throws an error: TASK [NGINX : copy html file]…
Asier Gomez
  • 6,034
  • 18
  • 52
  • 105
72
votes
6 answers

Skip Ansible task when running in check mode?

I'm writing an Ansible playbook and have a task which will always fail in check mode: hosts: ... tasks: - set_fact: filename="{{ansible_date_time.iso8601}}" - file: state=touch name={{filename}} - file: state=link src={{filename}}…
augurar
  • 12,081
  • 6
  • 50
  • 65
71
votes
1 answer

How to create a relative symlink in Ansible?

In my playbook, I need to create a symbolic link for a repo. With command (shell) it may work like this: ########## Create symbolic link - name: Create symbolic link shell : ln -s "{{SOURCE_FOLDER}}" SYMLINK args : chdir :…
firasKoubaa
  • 6,439
  • 25
  • 79
  • 148
71
votes
7 answers

Why does Ansible show "ERROR! no action detected in task" error?

Ansible shows an error: ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path. What is wrong? The exact transcript is: ERROR! no action detected in task. This often indicates a misspelled…
techraf
  • 64,883
  • 27
  • 193
  • 198
71
votes
10 answers

Ansible: how to construct a variable from another variable and then fetch it's value

Here is my problem I need to use one variable 'target_host' and then append '_host' to it's value to get another variable name whose value I need. If you look at my playbook. Task nbr 1,2,3 fetch the value of variable however nbr 4 is not able to…
Max
  • 1,202
  • 1
  • 13
  • 21
71
votes
7 answers

How to make Ansible execute a shell script if a package is not installed

How can I make Ansible execute a shell script if a (rpm) package is not installed? Is it somehow possible to leverage the yum module?
Kimble
  • 7,295
  • 4
  • 54
  • 77
70
votes
4 answers

How to retry Ansible task that may fail?

In my Ansible play I am restarting database then trying to do some operations on it. Restart command returns as soon as restart is started, not when db is up. Next command tries to connect to the database. That command my fail when db is not up. I…
Bartosz Bilicki
  • 12,599
  • 13
  • 71
  • 113
70
votes
7 answers

Using set_facts and with_items together in Ansible

I'm currently using Ansible 1.7.2. I have the following test playbook: --- - hosts: localhost tasks: - name: set fact 1 set_fact: foo="[ 'zero' ]" - name: set fact 2 set_fact: foo="{{ foo }} + [ 'one' ]" - name: set fact 3 …
Bruce P
  • 19,995
  • 8
  • 63
  • 73
68
votes
10 answers

Ansible: Get all the IP addresses of a group

Let's imagine an inventory file like this: node-01 ansible_ssh_host=192.168.100.101 node-02 ansible_ssh_host=192.168.100.102 node-03 ansible_ssh_host=192.168.100.103 node-04 ansible_ssh_host=192.168.100.104 node-05…
Forivin
  • 14,780
  • 27
  • 106
  • 199
67
votes
5 answers

Ansible - Save registered variable to file

How would I save a registered Variable to a file? I took this from the tutorial: - hosts: web_servers tasks: - shell: /usr/bin/foo register: foo_result ignore_errors: True - shell: /usr/bin/bar when: foo_result.rc…
Maximilian Kindshofer
  • 2,753
  • 3
  • 22
  • 37
67
votes
6 answers

merging dictionaries in ansible

I'm currently building a role for installing PHP using ansible, and I'm having some difficulty merging dictionaries. I've tried several ways to do so, but I can't get it to work like I want it to: # A vars file: my_default_values: key =…
Berry Langerak
  • 18,561
  • 4
  • 45
  • 58
67
votes
9 answers

How to detect why Ansible playbook hangs during execution

Some of tasks I wrote start and never end. Ansible does not provide any errors or logs that would explain this, even with -vvvv option. Playbook just hangs and passing hours doesn't change anything. When I try to run my tasks manually (by entering…
dev9
  • 2,202
  • 4
  • 20
  • 29
64
votes
5 answers

Checking for multiple conditions using "when" on single task in ansible

I want to evaluate multiple condition in ansible using when, here is my playbook: - name: Check that the SSH Key exists local_action: module: stat path: "/home/{{ login_user.stdout }}/{{ ssh_key_location }}" register: sshkey_result …
Arbab Nazar
  • 22,378
  • 10
  • 76
  • 82
64
votes
5 answers

How to define private SSH keys for servers in dynamic inventories

I ran into a configuration problem when coding an Ansible playbook for SSH private key files. In static Ansible inventories, I can define combinations of host servers, IP addresses, and related SSH private keys - but I have no idea how to define…
Clark Zheng
  • 661
  • 1
  • 6
  • 7
63
votes
4 answers

Ansible. Fast way to check syntax?

Is there a way to check playbook syntax and variables? I'm trying to dry-run(--check) but for some reasons it works really slow. It looks like it tries to perform an action instead of just check the syntax I want to omit en errors like…
kharandziuk
  • 12,020
  • 17
  • 63
  • 121