Questions tagged [ansible-playbook]

468 questions
2
votes
2 answers

Ansible parsing a JSON output

I'm using URI in order to get a JSOn output to a register called "vchosts" TASK [debug]…
Vidanez
  • 21
  • 1
  • 2
2
votes
1 answer

How to distribute SSH sessions via load balancer?

I have servers set up that look something like the diagram attached. I am trying to ssh into one of the build servers in the auto scaling group via the load balancer(NLB), but getting the following error…
d-_-b
  • 153
  • 1
  • 7
2
votes
1 answer

ansible-playbook 2.5 doesn't find group vars when specifying an inventory file directly

I've been using ansible scripts for some one shot tasks, for example doing a firstsetup after provisioning a VM. I have a script that creates a temporary inventory file, uses it to run an ansible playbook and deletes the temporary file…
Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
2
votes
1 answer

Ansible jinja2 template: How to loop through sub-elements of interface facts

There's a unappreciated but very useful answer here which explains how to loop through the interface facts for an arbitrary number of interfaces. Basically, it comes down to this: debug: msg: "{{ hostvars[inventory_hostname]['ansible_%s' |…
Graham Nicholls
  • 291
  • 2
  • 5
  • 13
2
votes
1 answer

How do I read Ansible variables from inventory files?

I can't figure out variables and I'm hoping some kind person can point me in the right direction. I have three files: group_vars/all --- env2: server hosts [all:vars] env=development [webservers] 138.78.334.247 site.yml --- - name: Provision…
Dafonz
  • 21
  • 1
  • 1
  • 2
2
votes
3 answers

How to get the docker version of the host in the dynamic inventory and/or Ansible facts?

We would like to do different things on hosts that run Docker 1.12 than on Docker 1.10 in Ansible. How can I obtain the version of Docker specified in my inventory, so that I can later say... Fetch all hosts that run Docker 1.10 on environment…
ujjain
  • 3,983
  • 16
  • 53
  • 91
2
votes
1 answer

Copying different config files depending on operating system

I want to distribute different config files depending on the OS version using Ansible. I'd like to distinguish the OS version with the ansible fact ansible_distribution so that I dont have to manually assign an OS version. The problem I have is that…
Ansgar
  • 123
  • 4
2
votes
1 answer

Ansible: Extract value from the register variables to use it in other plays within same playbook

I'm setting up a complete environment using Ansible. For some reason, Ansible is not picking up variable values. I'm using Ansible 2.1.1.0. Here's a strip example of what I'm trying to do: I have registered my vpc with register: ec2_vpc. syntax-1…
2
votes
1 answer

Via ansible change password of non-root account using passwd command and picking old password from ansible files

I have got a lot of systems having a common username to login. The password is also same for most of the systems. I have 1 inventory file with all the systems. For the systems that have a different password, I have saved the password against the…
Aseem
  • 79
  • 1
  • 3
  • 14
2
votes
1 answer

Ansible-pull does not find vars in group_vars directory

I have an ansible structure that contains some roles. /usr/local/ansible playbooks roles role1 role2 tasks handlers files templates …
Ed Greenberg
  • 306
  • 2
  • 6
2
votes
1 answer

ERROR! unexpected parameter type in action Ansible Playbook

I have my playbook yml script below: --- - name: Download files from FTP hosts: localhost gather_facts: false vars_prompt: - name: target_host prompt: "Target Host IP: " - name: auth_method prompt: "Authentication method…
2
votes
1 answer

Vmware tags and Ansible , empty out in Ansible but VMs have tags

I am trying to filter out the list of VMs with specific tags. The sample playbook is as follows : - hosts: localhost gather_facts: false become: false vars: vcenter_hostname: vcenter3423 vcenter_username: center\user4325 …
uozzyy
  • 23
  • 3
2
votes
1 answer

Ansible: How to merge list of dictionary objects with the same key getting one dictionary element with a list of thouse different values grouped?

I have been struggled with Ansible for a time and finally requesting for any help if possible, Having a set of Nifi policies: "nifi_raw_policies": [ { "action": "read", "group": "8c052e6c-0184-1000-0000-000072a0bb44", …
2
votes
4 answers

Ansible: "You need to install 'jmespath' prior to running json_query filter", but it is installed

I am using Ansible on top of Python3 and Enterprise Linux 8 (Rocky Linux 8). When I try to use json_query, I am getting the following error: fatal: [ansible]: FAILED! => {"msg": "You need to install \"jmespath\" prior to running json_query…
norinori
  • 81
  • 1
  • 8
2
votes
2 answers

Ansible Handlers failing when using with include_tasks

This ansible script works. --- - name: Create Swap hosts: serverName gather_facts: yes become: true become_user: root become_method: sudo tasks: - name: Create swap shell: 'dd if=/dev/zero of=/tmp/swapfile bs=1024…