Questions tagged [ansible]
Use this tag for questions about Ansible, an open-source automation engine, related to using Ansible for topics such as cloud provisioning, configuration management, application deployment, etc.
436
questions
55
votes
5
answers
17k
views
How is Ansible different from simply running a provisioning bash shell in Vagrant?
A team of IT sysadmins that have exprience using shell scripting to solve their problems, are contemplating to start using Ansible instead.
Are there substantial differences and good reasons to start ...
37
votes
6
answers
6k
views
How to test provisioning and configuration in Ansible setup?
Looking at trying to build some resilience into our Ansible setup which deals with provisioning and configuration.
I understand a few methods of testing on the configuration side of things but I'm ...
34
votes
3
answers
71k
views
Can I bypass host key checking in Ansible?
I'm running an Ansible playbook with a subtle hack to work on an arbitrary port forwarded port (so I can use one machine with no direct access to lots of machines).
I've got a pre-task to change ...
34
votes
5
answers
25k
views
Where to put ansible-vault password
We are planning to use ansible vault in our project to prevent leaking passwords or keys in git.
The idea is to put all our sensitive data into a plain file then encrypt this file with ansible-vault ...
33
votes
3
answers
48k
views
Is there a way to run with_items loops in parallel in Ansible?
I'm running Ansible 2.2, but can upgrade if it helps.
I saw this and was pretty excited, but it doesn't seem to be in this (or any) version of Ansible documentation.
The problem I'm trying to solve ...
26
votes
4
answers
47k
views
Ansible: Other option available for telnet check of open ports?
I'm new to Ansible. Here's my task ...
I have 400+ hosts, and I need to verify if 5 different ports are open from their end to our web server.
Individually, I could log in and run:
telnet ...
26
votes
1
answer
18k
views
Ansible: What's the difference between task, role, play and playbook?
Ansible has tasks, roles, plays and playbooks.
Are those just names for different levels in a playbook organization?
If not, how, exactly, do they differ from and relate to each other?
23
votes
1
answer
1k
views
Git clean/smudge filters for ansible vault secrets
I am trying to setup clean/smudge filter in git to have automatic encrypting and decrypting of files containing secrets thru ansible-vault command.
Peculiarity of the ansible-vault command is that it ...
22
votes
3
answers
54k
views
Execute multiple Ansible tasks with the same list of items
I am using an ansible playbook to configure Apache for a list of sites. The playbook has to copy the virtual host configuration template for each site into place, and then enable each site using ...
21
votes
3
answers
2k
views
What are the limitations of Puppet in comparison to Ansible?
I would like to understand the differences between Puppet and Ansible, especially what kind of Puppet limitations has in comparison to Ansible.
Are there any things you cannot do it in Puppet, but ...
21
votes
2
answers
13k
views
What is Ansible's config equivalent of `--vault-password-file`?
According the help of ansible-playbook one could use --user=REMOTE_USER to define the ssh user, but one could also define ansible_ssh_user: REMOTE_USER in either the host- or group_vars.
Question
...
18
votes
2
answers
7k
views
How do I run ansible on one host at a time and break on a failure
I've got an Ansible playbook where I want to update a number of flaky devices in sequence. I can use serial:1, but I want to stop the playbook altogether if I get a failure so I can fix it before ...
18
votes
1
answer
7k
views
How to keep configuration files automatically during apt-get upgrade or install?
When performing and apt-get update; apt-get upgrade -y on a server I encountered the message:
Setting up sudo (1.8.16-0ubuntu1.5) ...
Configuration file '/etc/sudoers'
==> Modified (by you or by ...
17
votes
4
answers
25k
views
How do I configure SSH keys in a Vagrant multi-machine setup?
I have 4 VMs in my Vagrantfile - 3 application servers and an Ansible control host.
I only use Vagrant to create the VMs as I provision them manually from the ansible control host because I am still ...
15
votes
2
answers
4k
views
What is ansible-runner about?
I've read the README file from the github repository as well as the documentation site of ansible-runner (from the official ansible project) but I don't understand what is ansible-runner about and in ...
14
votes
2
answers
20k
views
Ansible Playbook Localhost Invocation Working Directory
I want to run an ansible playbook locally (host is localhost, like -i "localhost,") and inside the Playbook obtain the working directory from which the ansible-playbook command was invoked.
However, ...
14
votes
1
answer
729
views
How do you manage your inventory of spot instances on AWS with Ansible
I am new to Ansible, with some experience in Chef. I am considering learn and use Ansible to manage environments.
I was wondering, what would be the best practice to manage inventory of AWS spot ...
13
votes
2
answers
4k
views
How do I run Ansible Azure playbooks while avoiding storing credentials in files?
Background
We use Ansible to provision and manage Azure infrastructure. At the moment we run Ansible "manually" i.e. we manually execute playbooks for various automated tasks. No CI infrastructure.
...
12
votes
5
answers
2k
views
Are configuration management tools appropriate to use as deployment tools?
Off the back of my answer to the question: How can DevOps help to improve Software Escrow procedures? Tensibai had the question:
What would necessitate Capistrano on top of puppet or chef?
My ...
12
votes
3
answers
464
views
How to safeguard Ansible deployment to mitigate accidents?
Recently the Amazon S3 had a major outage in the us-east-1 region. It looks like it was likely caused by a spelling error when running a maintenance playbook in Ansible or a similar tool. You can put ...
12
votes
7
answers
67k
views
How Do I Log Task Output To A File?
One of my ansible tasks imports an Oracle database using impdp.
This generates a lot of output to the console so I have set no_log: True.
However, when this fails I want to see the log!
How can I ...
12
votes
1
answer
1k
views
How to deterministic and reproducibly assign increasing port numbers in Ansible?
I am new to Ansible, but I have to maintain a set of playbooks, which correspond to services to be setup in a given environment. They need to be assigned a port, certificates, etc. This results in ...
11
votes
4
answers
3k
views
How to structure DevOps related code and configs in a code repository?
We've been growing as a company, our products are expanding and our DevOps related activities and efforts are growing as well - we've switched from Bamboo to a more flexible and configurable Jenkins, ...
11
votes
2
answers
2k
views
How should I store my environment variables?
This is a very broad question about methods and advice regarding environment variables / structure. But ultimately I'm looking for answers for the very specific question of 'How should I store my ...
11
votes
3
answers
21k
views
ansible: difference between a variable and a fact
While I'm using Ansible for quite some time, I'm not sure I really understand the differences between a variable and a fact.
Would it be any difference doing
- set_fact:
nginx_ssl: /etc/nginx/ssl
...
11
votes
2
answers
3k
views
Ansible Dynamic Inventory - generate inventory with ip addresses under specific tag with underscore instead of dot
I am new to Ansible. When I am using ec2.py dynamic inventory to generate inventory, after the playbook is finished to run, the results are shown as list of IP addresses under specific tag with ...
11
votes
1
answer
3k
views
How to automatically remove a dead node from RabbitMQ cluster
I am planning to create RabbitMQ cluster using Ansible on AWS VPC with Amazon internal load balancer as the frontend to point connections to it.
Any suggestion how to remove a dead node from RabbitMQ ...
10
votes
4
answers
23k
views
Playbook without relative path to vars
I had already bunch of playbooks, so I started to organize them in playbooks dir. It cause there must be relative paths to vars files.
Actual playbook:
---
- hosts: aws_instance.jenkins-agents
...
10
votes
2
answers
19k
views
How to run Ansible with sudo no password commands with become syntax
When I run ansible against a host machine that has some commands I need to run as root, I can't run these with "become" because it runs the commands as root instead of just running them with sudo.
...
10
votes
2
answers
260
views
Deploying VMs using roles and hosts in Ansible based on operating system
I'm having issues working out how to best apply hosts/roles to different operating systems in Ansible.
I'm currently using Ansible to generate Windows/Mac/Linux VMs, and each of the VMs have ...
9
votes
3
answers
9k
views
Is there an ansible module that check whether a port is not in LISTEN state?
The Ansible module index has been consulted, but no module was found that checks whether a port is available? Is there a module that supports this?
What does available mean?
Available means that a ...
9
votes
1
answer
6k
views
Ansible: Exclude a parameter if variable is not set
Is there a way to exclude a parameter entirely if a variable is not set? I do not want to use a default value for this, I simply do not way the parameter referenced at all.
For example,
---
- name: ...
9
votes
5
answers
2k
views
Questions about Ansible connection to remote hosts
I want to ask some questions about working of Ansible.
1 - Which shell Ansible uses when logging to remote host ?
https://askubuntu.com/questions/937354/track-logins-made-via-non-interactive-shells/...
9
votes
2
answers
13k
views
Modify sudoers file with ansible playbook template
I am trying to create a sudoers file with ansible template. The sudoers file should look like below:
Cmnd_Alias LS = /bin/ls
Cmnd_Alias LESS = /usr/bin/less
Cmnd_Alias DU = /usr/bin/du
%support1 ALL=...
9
votes
1
answer
5k
views
How to notate ipv6 addresses in inventory file?
I have a machine, that is accessible via ipv6 only. It is setup for ssh with rsa key. Now I'd like to manage it with ansible. Unfortunately, this is not covered in the inventory documentation.
So I ...
8
votes
2
answers
7k
views
Artifactory vs Git for Infrastructure Version Control / Configuration Management
I'm trying to understand the difference between managing configuration files for the purposes of simplifying automated deployment.
We have 5 environments to build. So far 2 have been built with no ...
8
votes
2
answers
59k
views
Passing variables between scripts in a Jenkins pipeline
I have a declarative Jenkins pipeline that looks like the following:
pipeline{
agent {
...
}
stages {
stage("Provision EC2 Instance and Set ENV Variable"){
...
8
votes
3
answers
3k
views
Using SSH to open interactive session in ansible
Is there a semi-easy way to use Ansible to open an interactive session?
I've spent a good amount of time making use of keys and other credentials stores to make a stellar ansible inventory file. ...
8
votes
1
answer
2k
views
How to organize infrastructure as code projects?
I have completed an Infrastructure-as-Code project using Terraform and Ansible. Currently, I organize my project as follows:
Project1
Terraform
ec2.tf
rds.tf
…
variables....
8
votes
1
answer
2k
views
Referencing current variable in Ansible conditional statement?
I'm using the willshersystems.users role from ansible galaxy for creating users on ubuntu servers. Now that I've got it working consistently, I'm trying to set the state attribute based on whether the ...
8
votes
1
answer
714
views
Vagrantfile change with Ansible playbook to control file permission on Vagrant synced folder for Trellis
I use Trellis for my WordPress development. It works great, except I'm finding it hard to change file (or directory) permission within the synced folder.
Generally I'm OK with the default permission ...
8
votes
2
answers
2k
views
Ansible sporadic errors with Windows machines
I'm running into some on and off issues when using windows hosts in my Ansible playbooks. I'm running Ansible 2.3 with pywinrm 0.2.2 installed. I'm using basic authentication with the local ...
8
votes
1
answer
315
views
Ansible playbook for configuring runit to supervise an uberjar?
We are using Ansible 1.9 for deploying Spring Boot microservices. We are using CentOS 6 and the services are packaged as rpms. We intend to configure the executable jar files to be supervised by ...
8
votes
1
answer
1k
views
What are best practices of deploying docker-compose using Ansible?
Ansible is used to deploy docker-compose on a system and subsequently start the container.
When ansible runs from the local system, the docker-compose file is deployed using Ansible.
When the code ...
7
votes
2
answers
15k
views
Applying ansible playbook to a docker container on a remote host
I have automated the setup of several docker containers with ansible. This works pretty well but there are certain recurring tasks that have to be executed within the docker containers.
It is possible ...
7
votes
3
answers
3k
views
Re-using Python virtual environments on a build server
Currently, every time we run a build through Jenkins+Ansible, we are re-creating a virtual environment and re-installing all the dependencies listed inside the requirements.txt file.
This is very ...
7
votes
1
answer
16k
views
Ansible how to know what return value is provided by a specific module
From Ansible's official doc
Ansible modules normally return a data structure that can be registered into a variable, or seen directly when output by the ansible program
and
Ansible modules ...
7
votes
4
answers
3k
views
Ansible - private git repositories - SSH agent forwarding vs copying private SSH key
I recently started playing around with Ansible and it seems very nice. I don't have much experience in DevOps stuff and never really had to handle any complex scenarios. I started creating my Ansible ...
7
votes
1
answer
1k
views
How does Vagrant differ from Ansible and Docker?
I understand that Ansible is a Configuration Management (CM) tool for orchestrating, deploying (and continuously upgrading) software and conf via a special YAML format created for that software, and ...
7
votes
2
answers
1k
views
How to solve "E405: Remote package tasks should have a retry" in Ansible?
E405 v4.0.0 Remote package tasks should have a retry Package
operations are unreliable as they require network communication and
the availability of remote servers. To mitigate the potential
...