Questions tagged [ansible]

Ansible is an IT automation tool. Use this tag for questions regarding the Ansible IT automation tools.

273 questions
87
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,…
36
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
  • 873
  • 2
  • 17
  • 41
29
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
  • 393
27
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
  • 1,026
25
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…
24
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
  • 489
24
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…
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
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
  • 1,026
11
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…
10
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
  • 245
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
8
votes
0 answers

Writing toml sections with ansible

I have an Ansible setup for "Gitlab Runners". These use toml as configuration format [[runners]] name = "gitlab-runner-1" url = "https://example.com" token = "x" executor = "docker" [runners.custom_build_dir] [runners.cache] …
madflow
  • 310
  • 2
  • 9
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…
6
votes
2 answers

Ansible error “ Could not find or access on Ansible Controller”

I am trying to write an ansible playbook to send certificates to my client machines from my local machine. The error message I get is: msg": "Could not find or access '/etc/icinga2/pki/clienthostname.crt' on the Ansible Controller.\nIf you are…
manhasnoname
  • 173
  • 2
  • 6
  • 12
1
2 3
18 19