Questions tagged [ansible-2.x]

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems

Ansible 2.x is a new backwards-incompatible version that involved a rewrite of the core, and a new API.

Ansible 2.x features new commands like ansible-vault, allowing you to store encrypted information in playbooks and have them decrypted on the fly. It also includes new concepts like Task Blocks, Dynamic Includes, Execution Strategy Plugins, and a suite of new "batteries included" modules. Most importantly, new releases are named after Led Zepplin songs, rather than Van Halen.

https://raw.githubusercontent.com/ansible/ansible/stable-2.0/CHANGELOG.md

Related Tags

1908 questions
11
votes
1 answer

Ansible: Use variable for defining playbook hosts

I have the following version installed: ansible 2.3.0 (devel 2131eaba0c) I want to specify my host variable as external variable and then use it in the playbook similar to this: hosts: "{{integration}}" In my group_vars/all file I have the…
Vetemi
  • 784
  • 2
  • 9
  • 26
11
votes
1 answer

Filter a substring matching a pattern from an ansible variable and assign matched substring to another variable

Let's say we have a long ansible string variable mystr. We have a regex pattern say substr_pattern and a substring matching this pattern is to be filtered out from mystr and to be assigned to another variable substr. There seems to be no obvious way…
Pranjal Mittal
  • 10,772
  • 18
  • 74
  • 99
10
votes
5 answers

Ansible - is it possible to add tags to hosts inside inventory?

As the topic says, my question is if its possible to add tags to the hosts described inside the inventory? My goal is to be able to run the ansible-playbook on specific host/group of hosts which has that specific tag e.g only on servers with tag…
rivar_
  • 334
  • 1
  • 4
  • 17
10
votes
2 answers

Ansible looping through files

Prior to Ansible 2.5, the syntax for loops used to be with_x. Starting at 2.5, loop is favored and with_x basically disappeared from the docs. Still, the docs mention exemples of how to replace with_x with loop. But I'm clueless as to how we're now…
Buzut
  • 4,875
  • 4
  • 47
  • 54
10
votes
1 answer

Ansible stops connecting to the host via ssh

Introduction For over a month I've been running the following command: ansible-playbook -vvvvi host_test rhel-tests.yml Which connected via SSH and ran tests on a host successfully without any problems. But as of the last couple days, I've received…
karobar
  • 1,250
  • 8
  • 30
  • 61
10
votes
2 answers

password not being accepted for sudo user with ansible

I am running an ansible playbook as a sudo user (forcing the sudo password) - however, I am getting a response stating that the su password is incorrect even though I can do the following on the remote server (with the same password that I tried…
ali haider
  • 19,175
  • 17
  • 80
  • 149
9
votes
2 answers

Setup windows 10 workstation using Ansible installed on WSL

I have installed Ansible in the WSL (Windows Subsystem for Linux) within my Windows 10 workstation. My goal is configure both, WSL, and the Windows 10 itself. I'm able to run playbooks against localhost, which connect and configures via SSH the…
vecin
  • 503
  • 5
  • 15
9
votes
3 answers

Ansible 2.6: Is there a way to reference the playbook's name in a role task?

Given a playbook like this: - name: "Tasks for service XYZ" hosts: apiservers roles: - { role: common } Is there a way to reference the playbook's name ("Tasks for service XYZ")? (i.e. a variable) EDIT: My intention is to be able to…
Diego Shevek
  • 486
  • 3
  • 15
9
votes
1 answer

Ansible check if key/value pair exists in list of dictionaries

I am trying to check if a certain key/value pair exists in a list of dictionaries in Ansible. I found this question, however I am not sure if the syntax differs from python to ansible (I have never seen an if statement in ansible!) Check if value…
astrade
  • 222
  • 1
  • 3
  • 10
9
votes
1 answer

How to solve TemplateRuntimeError: no test named 'equalto' in Ansible?

Ansible v2.2.1.0 I have task that collects information over items, and I setup a register for the task. For example, I use jq to parse a JSON file, hello.json ---------- { "name" : "hello file", "english" : "hello", "spanish" : "hola", …
Chris F
  • 14,337
  • 30
  • 94
  • 192
9
votes
2 answers

Undefined variable when running Ansible play

I am running multiple ansible plays defined in YAML files. In the last play I get the following error: {"failed": true, "msg": "The conditional check 'ansible_os_family == \"RedHat\"' failed. The error was: error while evaluating conditional…
Souciance Eqdam Rashti
  • 3,143
  • 3
  • 15
  • 31
9
votes
2 answers

Ansible timezone module fails (different reasons on different OSes)

I decided to refactor some playbooks and give a try to the new timezone module. The task I try is a verbatim copy of the example given in the manual page: - name: set timezone to Asia/Tokyo timezone: name: Asia/Tokyo It fails on each system I…
techraf
  • 64,883
  • 27
  • 193
  • 198
9
votes
3 answers

Ansible writing output from multiple task to a single file

In Ansible, I have written an Yaml playbook that takes list of host name and the executes command for each host. I have registered a variable for these task and at the end of executing a task I append output of each command to a single file. But…
user3059993
  • 324
  • 1
  • 4
  • 9
9
votes
2 answers

Warning while constructing a mapping in Ansible

Whenever I run my playbook the following warning comes up: [WARNING]: While constructing a mapping from /etc/ansible/roles/foo/tasks/main.yml, line 17, column 3, found a duplicate dict key (file). Using last defined value only. The relevant…
Cobra Kai Dojo
  • 1,018
  • 2
  • 12
  • 25
8
votes
2 answers

Ansible service task fails with "Could not find the requested service XXX"

I am trying to create ansible playbooks to install and configure kerberos on centos7. I have a task which yum installs the required rpms - name: install kerberos yum: name={{ item }} state=present with_items: - krb5-server -…
ayyrex
  • 323
  • 2
  • 3
  • 6