Hot answers tagged

40 votes
Accepted

How is Ansible different from simply running a provisioning bash shell in Vagrant?

I never used Ansible but since a few weeks, I try to figure out what good Ansible could be in comparison with shell scrips–Which proves, at least in my case, that the haunting ad-campaigns they run ...
Michaël Le Barbier's user avatar
38 votes

Can I bypass host key checking in Ansible?

This is typically done by setting the following value in ansible.cfg: [defaults] host_key_checking = False If you don't want to modify ansible.cfg you can set an environment variable like so: ...
Zlemini 's user avatar
34 votes
Accepted

Ansible: Other option available for telnet check of open ports?

You can use the Ansible wait_for module which checks a specific TCP port is open. Since in this case, all ports should be open already, we can use a minimal no. of retries, just enough to cover ...
RichVel's user avatar
  • 872
31 votes

Is there a way to run with_items loops in parallel in Ansible?

As @webKnja mentioned this is possible with async mode. I have recently discovered it myself and learned that you can use it in 3 different ways depending on your needs. Execute and poll the results, ...
MMT's user avatar
  • 411
31 votes
Accepted

Ansible: What's the difference between task, role, play and playbook?

No, each has a different role and way of working. Starting with the easy ones: A playbook is simply a list of plays. The highest level of a playbook YAML is a list, and on that list only two things ...
caxcaxcoatl's user avatar
27 votes

Can I bypass host key checking in Ansible?

In your ansible.cfg file you need to add the following line: ssh_args = -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no You could also add those options in your ~/.ssh/config on every ...
Jiri Klouda's user avatar
  • 5,807
25 votes

How is Ansible different from simply running a provisioning bash shell in Vagrant?

When you put it this way, even if Ansible has some inherent advantages, the benefits of using familiar tools (in this case shell scripting) must be outweighed. I don't think there's a clear cut answer ...
Assaf Lavie's user avatar
  • 1,241
24 votes
Accepted

How to test provisioning and configuration in Ansible setup?

Some options out there.. Testing tools: Sorted by github stars Serverspec - Ruby, most popular tool out there, built on ruby's rspec Goss - YAML, simple, <10MB self-contained binary, extremely ...
Ahmed Elsabbahy's user avatar
21 votes
Accepted

What are the limitations of Puppet in comparison to Ansible?

There are of course several pro and cons for each of Puppet, Ansible, Chef and add your favorite tool here as well. So I'll try to stay away from opinion, and share what is great in Ansible as a ...
ᴳᵁᴵᴰᴼ's user avatar
21 votes

Execute multiple Ansible tasks with the same list of items

Make separate tasks file make_site.yml: --- - name: Install apache site conf template: src: apache-sites-{{ site }}-conf.j2 dest: /etc/apache2/sites-available/{{ site }}.conf mode: 0644 ...
Konstantin Suvorov's user avatar
17 votes
Accepted

Ansible Playbook Localhost Invocation Working Directory

You can use env lookup plugins. Plugins are always evaluated in the context of "parent" ansible process on the control host. - debug: msg: "{{ lookup('env', 'PWD') }}" More lookup plugins can be ...
Konstantin Suvorov's user avatar
17 votes
Accepted

How to keep configuration files automatically during apt-get upgrade or install?

There are options you can pass through apt-get to dpkg that will handle the config choices. We usually do something like: apt-get install -y --no_install_recommends -o Dpkg::Options::='--force-...
Jiri Klouda's user avatar
  • 5,807
16 votes

How do I run ansible on one host at a time and break on a failure

Your playbook will stop when a failure occurs and you're using serial: 1 according to the documentation. By default, Ansible will continue executing actions as long as there are hosts in the group ...
Woodland's user avatar
  • 1,338
15 votes
Accepted

How do you manage your inventory of spot instances on AWS with Ansible

You are looking for Dynamic Inventory Please look into ec2.py and ec2.ini of Ansible, and also the Dynamic Inventory docs of Ansible are very good for understanding how to manage your AWS inventory.
Dawny33's user avatar
  • 2,826
15 votes
Accepted

What is Ansible's config equivalent of `--vault-password-file`?

Here is the definition: DEFAULT_VAULT_PASSWORD_FILE = get_config(p, DEFAULTS, 'vault_password_file', \ 'ANSIBLE_VAULT_PASSWORD_FILE', None, value_type='path') This means that you either put in ...
Jiri Klouda's user avatar
  • 5,807
15 votes
Accepted

Where to put ansible-vault password

The idea is to put all our sensitive data [...] The meaning of "all" in this sentence should be analyzed very carefully before implementing the solution that you plan. Ansible vault is a very useful ...
Vincenzo Pii's user avatar
14 votes

How is Ansible different from simply running a provisioning bash shell in Vagrant?

The above answer covers part of it but misses one of the important elements: convergent design. I wrote some words a while ago about this in the context of Chef at https://coderanger.net/thinking/ but ...
coderanger's user avatar
  • 1,197
14 votes
Accepted

Applying ansible playbook to a docker container on a remote host

With the help of @Levi (refered to Stackoverflow) I managed to find a way to connect straigt into the docker containers using ansibles docker connection driver and the remote API capability of Docker. ...
davidb's user avatar
  • 399
13 votes

How should I store my environment variables?

I've had two runs at doing environment variables in a scalable way and neither has ended up perfect because, as I've discovered, is a very tricky thing to get right. I'll give a summary of both of my ...
hvindin's user avatar
  • 1,734
12 votes

How to test provisioning and configuration in Ansible setup?

The two tools I've seen for this are InSpec and ServerSpec. Serverspec is a Ruby-based tool that builds on RSpec. InSpec is inspired by RSpec and ServerSpec. I've used ServerSpec. It's cool, but ...
Dave Swersky's user avatar
  • 4,068
12 votes
Accepted

Is there an ansible module that check whether a port is not in LISTEN state?

I think you're looking for the wait_for module. It will allow you to check and make an action when a certain port is available and more.
13dimitar's user avatar
  • 757
12 votes
Accepted

What is ansible-runner about?

This project is to support automation of running ansible playbooks. There is a GUI based project called Ansible Tower or AWX to do that, but ansible-runner seems to be the underlying layer of the ...
Jiri Klouda's user avatar
  • 5,807
11 votes

What are the limitations of Puppet in comparison to Ansible?

No, people moving away from Puppet to Ansible (or vice versa) has nothing to do with what can or cannot be accomplished with either tool. Puppet/Chef/Ansible - it's mostly a matter of taste. For ...
Assaf Lavie's user avatar
  • 1,241
11 votes

How to test provisioning and configuration in Ansible setup?

When using configuration management tools, such as Ansible, the tool itself would be responsible preventing configuration drift. Once you used Ansible to set a certain configuration, repetitive ...
Evgeny Zislis's user avatar
10 votes
Accepted

Are configuration management tools appropriate to use as deployment tools?

In such context the typical advice should be immediately applicable: use the right tool for the job. But then you also cannot ignore nowadays the almost virulent tendency of software tools to extend ...
Dan Cornilescu's user avatar
10 votes

Where to put ansible-vault password

We are planning to use ansible vault in our project to prevent leaking passwords or keys in git. Since you haven't yet implemented anything, you might reconsider this. Using a system like Ansible ...
Xiong Chiamiov's user avatar
10 votes
Accepted

Ansible how to know what return value is provided by a specific module

if you do something like: - name: Launch instance ec2: register: data_struct You can then output all the values returned by doing this below the above code: - name: print all returned values ...
Zohaib Amanzai's user avatar
9 votes

Git clean/smudge filters for ansible vault secrets

The problem here is caused by the random salt in ansible-vault encryption. You can hack VaultEditor class to pass the salt to it from an argument in ansible-vault. The random salt is generated in lib/...
Jiri Klouda's user avatar
  • 5,807
9 votes
Accepted

Passing variables between scripts in a Jenkins pipeline

For Declarative Pipeline: This question already has a highly-upvoted answer on StackOverflow: If you want to use a file (since a script is the thing generating the value you need): pipeline { ...
jayhendren's user avatar
  • 2,932
9 votes
Accepted

How does Vagrant differ from Ansible and Docker?

Vagrant can complement Ansible and Docker. It is used to spin virtual machines inside which you install Docker and test your Ansible playbooks. You describe desired VM configuration with Vagrantfile ...
Konstantin Suvorov's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible