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
13
votes
1 answer

Ansible is skipping the debug line

I have this task in a role and a debug line beneath it: - name: Restore bootstrap DB command: "mongorestore -v --host localhost:{{ mongodb_net.port }} -d {{ item.dbname }} --dir {{ item.clone_dir }}" register: restore_result with_items: -…
FrancisV
  • 1,619
  • 5
  • 21
  • 36
13
votes
3 answers

Ansible: Multiple and/or conditionals in when clause

I am having issues when trying to use multiple and/or conditionals in a when statement to decide whether a task needs to be ran or not. Basically I am making a playbook to do automated system patching with options for security patches, kernel only…
Jay
  • 549
  • 1
  • 8
  • 18
13
votes
1 answer

How to use Ansible 2.0 Python API to run a Playbook?

I'm trying to write a python script which will call existing Ansible playbooks as it goes (because I want to loop over a list of plays while looping over a list of variables). This post explains it very well, for ansible pre-2.0: Running…
ddro
  • 201
  • 1
  • 3
  • 10
13
votes
4 answers

Update Ansible 1.9.4 to Ansible 2.0

I have uninstall ansible 1.9.4 and install with sudo apt-get install ansible, the version 2.0.2. But when I execute: ikerlan$ ansible --version ansible 1.9.4 I have uninstall and reinstall using ansible ppa, when I install I can see…
Asier Gomez
  • 6,034
  • 18
  • 52
  • 105
12
votes
3 answers

Ansible playbook fails to lock apt

I took over a project that is running on Ansible for server provisioning and management. I'm fairly new to Ansible but thanks to the good documentation I'm getting my head around it. Still I'm having an error which has the following output: failed:…
supersize
  • 13,764
  • 18
  • 74
  • 133
12
votes
2 answers

Ansible task - clone private git without SSH forwarding

I am trying to create an Ansible playbook which would be run from our dev team computers and from CI/CD servers. One of the tasks in the playbook is to get the source code of our project from a private git repository. Because the playbook has to run…
Laurynas Mališauskas
  • 1,909
  • 1
  • 19
  • 34
12
votes
1 answer

Set Ansible variable to undefined through extra-vars or inventory variable

So I have an Ansible playbook that looks like --- - hosts: mygroup tasks: - debug: msg: "{{ foo | default(inventory_hostname) }}" My inventory file looks like [mygroup] 127.0.0.1 Since foo is not defined anywhere, the debug prints…
Rickkwa
  • 2,197
  • 4
  • 23
  • 34
12
votes
2 answers

Ansible lineinfile - modify a line

I'm new to Ansible and trying to modify a line in /etc/default/grub to enable auditing. I need to add audit=1 within the quotes somewhere on a line that looks like: GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap…
Jeff Bilbro
  • 149
  • 1
  • 1
  • 9
12
votes
3 answers

In Ansible, How to connect to windows host?

I have been stuck with Ansible window module. I am just trying to ping windows machine.But i get 'connect timeout' hosts [windows] 192.168.1.13 group_vars/windows.yaml ansible_user: raja ansible_password: myPassword ansible_port:…
rajagopalx
  • 3,012
  • 9
  • 41
  • 52
12
votes
5 answers

Ansible: removing hosts

I know that one can add host with the following task: - name: Add new instance to host group add_host: hostname: '{{ item.public_ip }}' groupname: "tag_Name_api_production" with_items: ec2.instances But I can't seem to find a way to…
cscan
  • 3,684
  • 9
  • 45
  • 83
11
votes
1 answer

Ansible : The loop variable 'item' is already in use

I want to run a task in ansible something similar to the following. #Task in Playbook - name : Include tasks block: - name: call example.yml include_tasks: "example.yml" vars: my_var: item …
Kaushik Vijayakumar
  • 755
  • 3
  • 10
  • 19
11
votes
1 answer

How to use Ansible wait_for to check a command status with multiple lines?

Ansible v2.4.0.0 I'm installing Gitlab-CE where I run the following in an Ansible task. As you can see, some of the processes are down, but they eventually come up. # gitlab-ctl status run: gitlab-workhorse: 0s, normally up run: logrotate: 1s,…
Chris F
  • 14,337
  • 30
  • 94
  • 192
11
votes
2 answers

How can I run commands in sudo mode with ansible playbook?

I am trying to run a "folder creation" command with my ansible playbook. (Code is below) The creation requires sudo login to execute. I run the playbook as follows: ansible-playbook myfile.yml --ask-pass This prompts for user account password of…
Suzanno Hogwarts
  • 323
  • 2
  • 3
  • 12
11
votes
1 answer

Can Ansible deploy public SSH key asking password only once?

I wonder how to copy my SSH public key to many hosts using Ansible. First attempt: ansible all -i inventory -m local_action -a "ssh-copy-id {{ inventory_hostname }}" --ask-pass But I have the error The module local_action was not found in…
oHo
  • 51,447
  • 27
  • 165
  • 200
11
votes
1 answer

Ansible - How to check the physical memory and free disk is greater than some value?

How to write an ansible task to check if the physical memory >=128 MB and free disk is >= 256 MB. i tried to get the output but i am not sure how to proceed further. # Check the physical disk memory 128 MB and free disk 256 MB - name: check the…
user6826691
  • 1,813
  • 9
  • 37
  • 74