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
139
votes
4 answers

Write variable to a file in Ansible

I am pulling JSON via the URI module and want to write the received content out to a file. I am able to get the content and output it to the debugger so I know the content has been received, but I do not know the best practice for writing files.
Keith Adler
  • 20,880
  • 28
  • 119
  • 189
136
votes
5 answers

Ansible Playbooks vs Roles

According to the Ansible docs, a Playbook is: ...the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications. And,…
smeeb
  • 27,777
  • 57
  • 250
  • 447
132
votes
9 answers

Ansible: Can I execute role from command line?

Suppose I have a role called "apache" Now I want to execute that role on host 192.168.0.10 from the command line from Ansible host ansible-playbook -i "192.168.0.10" --role "path to role" Is there a way to do that?
Karl
  • 2,903
  • 5
  • 27
  • 43
130
votes
25 answers

Creating a new user and password with Ansible

I have an ansible task which creates a new user on ubuntu 12.04; - name: Add deployment user action: user name=deployer password=mypassword it completes as expected but when I login as that user and try to sudo with the password I set it always…
raphael_turtle
  • 7,154
  • 10
  • 55
  • 89
129
votes
4 answers

Ansible: Set variable to file content

I'm using the ec2 module with ansible-playbook I want to set a variable to the contents of a file. Here's how I'm currently doing it. Var with the filename shell task to cat the file use the result of the cat to pass to the ec2 module. Example…
TesterJeff
  • 1,626
  • 2
  • 16
  • 20
128
votes
3 answers

Run task only if host does not belong to a group

I'd like to able to run an ansible task only if the host of the current playbook does not belong to a certain group. In semi pseudo code: - name: my command command: echo stuff when: "if {{ ansible_hostname }} not in {{ ansible_current_groups…
rgrinberg
  • 9,638
  • 7
  • 27
  • 44
126
votes
6 answers

Ansible: Store command's stdout in new variable?

Inside my playbook I'd like to create a variable holding the output of an external command. Afterwards I want to make use of that variable in a couple of templates. Here are the relevant parts of the playbook: tasks: - name: Create variable…
Forivin
  • 14,780
  • 27
  • 106
  • 199
121
votes
9 answers

How can I copy files between two managed nodes using Ansible?

I need to copy a file between two remote nodes: node A is a managed node where the file exists node B is a managed node where the file should be copied Please note that my control node, from where I run all my Ansible tasks, is none of the above…
user3228188
  • 1,641
  • 3
  • 14
  • 19
115
votes
8 answers

How to use template module with different set of variables?

My use case is the following : I have a template file, and I would like to create 2 different files from that template, with the variables being filled by a different set of variables for each file. For example, lets say I want to template the file…
Kestemont Max
  • 1,302
  • 2
  • 8
  • 10
113
votes
10 answers

Escaping double curly braces in Ansible

How to escape double curly braces in Ansible 1.9.2? For instance, how can I escape double curly braces in the following shell command? - name: Test shell: "docker inspect --format '{{ .NetworkSettings.IPAddress }}' instance1"
Davide Guerri
  • 1,887
  • 2
  • 17
  • 25
113
votes
7 answers

How do I get logs/details of ansible-playbook module executions?

Say I execute the following. $ cat test.sh #!/bin/bash echo Hello World exit 0 $ cat Hello.yml --- - hosts: MyTestHost tasks: - name: Hello yourself script: test.sh $ ansible-playbook Hello.yml PLAY [MyTestHost]…
Kashyap
  • 15,354
  • 13
  • 64
  • 103
112
votes
7 answers

How do I get a variable with the name of the user running ansible?

I'm scripting a deployment process that takes the name of the user running the ansible script (e.g. tlau) and creates a deployment directory on the remote system based on that username and the current date/time (e.g.…
Tessa Lau
  • 1,469
  • 2
  • 12
  • 15
110
votes
3 answers

Ansible: filter a list by its attributes

I have variable named "network" registered in Ansible: { "addresses": { "private_ext": [ { "type": "fixed", "addr": "172.16.2.100" } ], …
Guido
  • 46,642
  • 28
  • 120
  • 174
109
votes
2 answers

How to copy files with ansible relatively to the role?

I have a copy task inside a role and I was expecting that the src location would be relative to the role itself, not the playbook that calls the roles. How do I make this work and use the files from myfrole/files from a task inside myrole/tasks, I…
sorin
  • 161,544
  • 178
  • 535
  • 806
108
votes
6 answers

ansible : how to pass multiple commands

I tried this: - command: ./configure chdir=/src/package/ - command: /usr/bin/make chdir=/src/package/ - command: /usr/bin/make install chdir=/src/package/ which works, but I was hoping for something neater. So I tried this: from:…
John Doe
  • 1,570
  • 3
  • 13
  • 22