Questions tagged [ansible]

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:

17487 questions
416
votes
23 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
  • 17,165
  • 28
  • 97
  • 157
270
votes
8 answers

Run command on the Ansible host

Is it possible to run commands on the Ansible host? 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 (tarballed) to the…
Ross
  • 43,016
  • 36
  • 114
  • 168
245
votes
13 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
  • 17,114
  • 7
  • 61
  • 76
242
votes
25 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
  • 21,036
  • 19
  • 98
  • 176
239
votes
10 answers

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

I'm new to ansible and wonder how to do so as the following 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.
222
votes
12 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
  • 2,986
  • 2
  • 11
  • 22
202
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,099
  • 6
  • 30
  • 33
196
votes
10 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
  • 29,394
  • 26
  • 118
  • 185
192
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,959
  • 2
  • 8
  • 5
175
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 cound't find a list of all available variables.…
neves
  • 20,547
  • 15
  • 108
  • 137
173
votes
19 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
  • 2,654
  • 2
  • 20
  • 38
172
votes
9 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
  • 7,732
  • 17
  • 48
  • 80
172
votes
3 answers

How to get the host name of the current machine as defined in the Ansible hosts file?

I'm setting up an Ansible playbook to set up a couple servers. There are a couple of tasks that I only want to run if the current host is my local dev host, named "local" in my hosts file. How can I do this? I can't find it anywhere in the…
Tanner Semerad
  • 12,033
  • 9
  • 35
  • 45
168
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
  • 46,078
  • 18
  • 137
  • 157
166
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,050
  • 7
  • 25
  • 43
1
2 3
99 100