Ansible is an IT automation tool. Use this tag for questions regarding the Ansible IT automation tools.
Questions tagged [ansible]
251 questions
84
votes
9 answers
Ansible: How to recursively set directory and file permissions
In ansible, I can do this:
file: dest=/foo/bar/somedir owner=root group=apache mode=0775 recurse=yes
And it recursively sets the owner, group, and permissions to 0775 on all directories and files in that path. But I want to set directories to 0775,…
Edward Ned Harvey
- 1,420
- 2
- 12
- 14
28
votes
3 answers
Ansible playbook to determine OS release
I'm simply trying to check the version of ubuntu on all my servers. Based on this question I see that ansible has a ansible_distribution_version but this playbook does not show how I would simply just have it print out the ubuntu version, ie ubuntu…
nadermx
- 667
- 1
- 10
- 32
24
votes
2 answers
How to count the number of elements in an array in Ansible?
An array is generated in Ansible from shell command output, it is similar to below:
foo: [value0, value1, value2, value3]
Now depending on output of the shell command, the number of elements of foo may vary.
I then generate a jinja2 template to…
frenchy59
- 343
- 1
- 2
- 4
24
votes
3 answers
How to set a default ssh user for all hosts in Ansible?
Ansible version 2.1
I have an inventory file hosts
[nodes]
host1
host2
...
And a simple playbook site.yml
---
- hosts: all
tasks:
- include: tasks/main.yml
If I just start the play,
ansible-playbook -i hosts site.yml -vvvv
I get this error…
Howard Lee
- 986
- 4
- 8
- 14
23
votes
2 answers
What is the significance of an Ansible task reporting that something has changed?
I have a task that checks if my process is listening on port 8080 and only when the exit code is not zero, would I run fail with a message.
When the service is running, it reports that the status has changed. I want it to say ok. What does a changed…
socgen hacker
- 417
- 1
- 4
- 10
23
votes
1 answer
Ansible Determine Operating System
As part of my deploy script I wanna check which operating system I am deploying to. I used ansible localhost -m setup and as they say in the documentation this outputs a lot. Is there a way I can just access the ubuntu distro I am using? Ideally I…
ford prefect
- 347
- 1
- 3
- 10
22
votes
4 answers
Can’t find the config file in “/etc/ansible/” on Mac OS X
I’m on Mac OS X and new to Ansible. I forget how I installed it. I think via pip:
$ pip freeze
altgraph==0.12
ansible==1.9.2
At any rate, from what I'm reading there should be a config file in /etc/ansible/, but the content of that directory is…
MikeiLL
- 469
- 2
- 5
- 14
14
votes
3 answers
Run a remote script/application in detached mode in Ansible
I am having trouble running a remote application startup script "detachedly" from an Ansible playbook. The script will run, but I can't get it to get/stay detached. I am probably doing something wrong, but what?
Here is my reproducer.
My remote…
SadBunny
- 1,416
- 2
- 12
- 15
14
votes
2 answers
Ansible task to confirm if a process is running
Ansible 2.1
In the playbook, I started a process:
- name: Start Automation Agent, and enable start on boot
service: name=mongodb-mms-automation-agent state=started enabled=yes
From play recap, it appears the process has successfully started.
TASK…
Howard Lee
- 986
- 4
- 8
- 14
9
votes
4 answers
Ansible command-task runs into "Exec format error"
I wrote this ansible task to run a process on a remote vagrant box. (Well, actually the ansible file itself is much longer, but this is a reproducer that only runs the start script.)
---
- hosts: myappname_server
vars_files:
-…
SadBunny
- 1,416
- 2
- 12
- 15
9
votes
5 answers
ansible: silently skip unreachable hosts
We use ansible to configure some hosts, including IP configuration. We do not want to use a DHCP server. Sometimes we add new hosts to the network.
Those new hosts are in one ip address range and the existing production hosts are in another. We just…
icehawk
- 235
- 2
- 4
- 7
7
votes
3 answers
Copy my ssh key to remote machine via ssh-copy-id in a script without prompt?
My usecase is that i need to copy my ssh key for authorized access onto a remote machine. I need to be able to call a script that copies over my ssh key to the remote machine without needing my input. Currently it prompts for a password and also a…
Aamir Mushtaq
- 175
- 1
- 1
- 5
7
votes
5 answers
Ansible installed via pip3, but Ansible commands not found
I have installed Ansible via pip3, but I can't find the Ansible commands (ansible --version, ansible-playbook, etc.)
Here's the listing that shows that Ansible is installed via pip3:
:~# pip3 list | grep ansible
DEPRECATION: The default format will…
Jinja_dude
- 207
- 1
- 3
- 9
6
votes
1 answer
ansible: execute local_action only once while running playbook against a group of hosts (multiple managed hosts)
Is it possible in ansible to make local_action task being run ONLY once while running playbook against a group of hosts?
Here is the problem:
hosts:
- macbooks
- localhost
tasks:
#......#
- local_action: command
…
drew1kun
- 2,088
- 7
- 41
- 59
6
votes
3 answers
Install Ansible in Windows, using Git-bash
I am trying to install the Ansible open source automation platform on Windows. There are many guides out there for how to install Ansible using Cygwin (eg. 1, 2).
However, I already have Git-Bash installed on Windows 7 (from here).
Is it possible to…
edesz
- 173
- 1
- 1
- 8