Questions tagged [ansible-inventory]

Use this tag for questions regarding the Ansible inventory defined either as a static file (aka hosts file), or dynamically through external scripts (for example AWS EC2 inventory).

0
votes
0answers
7 views

msg“: ”Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

When I run "ansible -m ping migservers -vvv" Im getting below error. ansible -m ping migservers -vvv ansible 2.8.1 config file = /mnt/git/smart-egw-pre-production/automation-scripts/release-...
0
votes
1answer
19 views

How to make ansible loop over hosts sequentially

I have set of tasks that i want to execute at set of hosts sequentially. Example is below. hosts: all tasks: - name: do some work include_tasks: tasks_here.yml loop: "{{ vars[play_hosts] }}" ...
0
votes
1answer
27 views

How to combine with_dict and with_sequence?

I'm trying to check if a JBoss management user has already been created. I have a working play: - name: Check if Management user has already been created shell: "grep -i '{{jbossvars.mgmt_user}}' {{...
0
votes
1answer
21 views

Why isn't Ansible able to parse my azure dynamic inventory config file?

I am trying to set up a dynamic inventory for Ansible to use with Azure, but I am getting some messages as Ansible is not able to parse my yaml file. What I did so far: Created Azure Service ...
1
vote
1answer
20 views

Ansible: overwrite inventory's ansible_host from command line

I have a simple inventory in hosts: dockermachine ansible_host=10.10.10.10 I need to be able to provide any other IP I wish from the command line, overwriting the default, something like: ansible-...
0
votes
2answers
23 views

Is it possible to merge anisible group_vars, if possible can you hlep me how to solve

Actually I have group_vars, I need to merge those vars, can you help me. group_vars/eu/main.yaml mgmt_routes: Tok: - ip: 172.22.203.253 netmask: 255.255.255.255 group_vars/all/main.yaml ...
0
votes
2answers
31 views

Make Ansible use the right IP

i'm currently having an odd problem with Ansible I used to change pretty often the IP address of my hosts in my hosts file. Didn't have any problem so far. But now, even though i changed the IP ...
-1
votes
0answers
25 views

How to enable/disable logs and debug using Ansible

I have a requirement for an application we are currently supporting. So the task is to write an ansible script that will disable and enable logs and debug. Any example script or playbook will be ...
0
votes
1answer
39 views

How to add items to an existing dictionary in Ansible?

I have a dictionary which is loaded by the following play: - name: Get variables from ../main.yml and save them into dict include_vars: file: "../main.yml" name: dict "dict" contains the ...
0
votes
1answer
36 views

Delegation a set of tasks to another host that relies on conditional

My question is slightly complex. I have some multi-node cluster infrastructure that orchestrated with Ansible. And there can be nodes that Kubernetes masters or slaves. Depending on that I need to ...
0
votes
2answers
15 views

Using Consul KV store for inventory details, possible?

Is it possible to use KV information from Consul to populate the inventory during runtime? I would like to pull KV information from Consul when running ansible-playbooks to populate the inventory ...
0
votes
1answer
40 views

How to perform a cyberarkpassword lookup for all hosts in an inventory group and write the keys out to individual pem files?

Ansible version 2.7.9 I'm writing an ansible playbook to deploy an piece of software to a linux environment. SSH access to these systems is protected by a CPM (Cyberark), used as an ssh key manager. ...
0
votes
0answers
7 views

Supplementing rather than overriding vars?

In deploying servers, we have a common "users" role, with a variable of the same name. The problem is that in our inventory, that variable of course gets clobbered by any subordinate group variable ...
0
votes
1answer
31 views

Get a list of inventory hostnames

host1: abc host2: xyz host1 and host2 are listed under test-hosts [test-hosts] abc xyz When i debug for inventory_hostnames, i see them like below > TASK [debug inventory_hostname] > ...
0
votes
2answers
20 views

Use host variables in ansible playbook

I'm trying to reference host variables in a playbook in combination with "with_items". My inventory [container] testcontainer-01.example.org template_name="syslog" ipv4="192.168.1.101" testcontainer-...
1
vote
1answer
41 views

how to enable openstack_inventory.py caching?

How to enable caching when running openstack_inventory.py? Mine does seems to cache and takes a long time to query the inventories for ansible.
0
votes
1answer
38 views

Ansible access same group vars different children host groups

I am trying to run a role which loops based on a parent group (or parent of parent group) with two or more child groups with certain number of hosts. The two child groups have same group_vars so I ...
0
votes
0answers
39 views

Ansible Inventory Grouping

I have ansible filtering option defined with following playbook. But when executed with centos user it is not filtering by user to run. I have to run this playbook 3 times with 3 different user: 1. ...
0
votes
2answers
38 views

How can I use a wildcard to include multiple files for using environment variables in Ansible?

I am trying to do a custom install of openedx and I have a bunch of .yml files with environment variables in them inside paths that looks like this playbooks/roles/<component-name>/defaults/...
0
votes
1answer
56 views

Unable to parse inventory directory

My inventories are defined in a modified default Ansible 'Hosts' file. When I specify the -i {inventory} {.yml} I receive an error. ansible 2.8.0 config file = /etc/ansible/ansible.cfg ...
0
votes
0answers
9 views

How to create a host group using VmWare inventories?

Using my vcenter inventory, I'd like to be able to use a property in the host and create a host group using that property Most of our infrastructure is in VmWare so I created an inventory using one ...
-2
votes
0answers
26 views

Ansible: How to call roles in a precious order through the heterogeneous inventory

I have to bootstrap several clusters via IDRAC interface (using dellemc_* modules) including the configuration of network devices (using ios_* & eos_* modules) with final provisioning of installed ...
0
votes
1answer
41 views

Use Ansible inventory IP in Playbook

I have an inventory file called inventory.ini which contains exactly just: 10.0.0.4 10.0.0.5 I would like to use the IPs listed here in the my Playbook under the variable ip_address: - name: Import ...
0
votes
1answer
20 views

AWX Failing to install requirements from private repo

I have an AWX installation with a project. The project is fetched perfectly from the private git repo. The project has a requirements file which is executed by AWX. The requirements file contains ...
0
votes
0answers
38 views

Ansible dynamic Inventory with bash script

We have recently built an API that allows us to query a list of VM's rather than using an inventory file. I am trying to incorporate this with our ansible set-up. I am very new to using a dynamic ...
0
votes
1answer
28 views

How to make a dict from a list in Ansible

So I have a list containing some items that I would like to format/transform to a dict. The current list looks as followed, (dummy content) users: - John - John_Doe - Jane - Jane_Doe Expected ...
0
votes
1answer
72 views

How to get a specific line from Ansible nested register output

So I'm trying to get a specific row/line from Ansible register output. But since my output is quiet nested I can't seem to get the right value I want. Playbook looks as followed, --- - name: Get ...
0
votes
1answer
31 views

Ansible: How to write a service-centric inventory?

Ansible usually works host-centric: If you have a host with some host variables in more than one group in an inventory then all variables for that host will be merged and those with the same name ...
0
votes
1answer
45 views

How to loop through two lists & add conditional statement to execute something when one condition is true

I have a question, i got the sid list & the DB open_mode, i am trying to run a sql script on the DB when below two conditions satisfy: DB name should end with '1'. DB Open_Mode should be 'READ ...
0
votes
2answers
33 views

How to conditionally replace text in a list with regex_replace?

I have a variable in my playbook that's derived from a list. In some instances this variable contains a "-" to separate two values. For example, Numbers: - 2211 - 2211-2212 When this is the case ...
0
votes
1answer
29 views

Ansible task is failing even with the right syntax

I am learning ansible and i have written a task for LDAP validation. However, when i run the playbook, the task is failing even when the validation is correct. Below is the ansible task which will ...
0
votes
1answer
25 views

How to execute task on all hosts from group when playbook is executed with limited hosts?

Scenario I have a group A in my inventory, where A contains a1,a2,a3 hosts. It does mean that I can write in my playbook X.yml: - hosts: A roles: - role: name: r The problem is about ...
0
votes
1answer
33 views

Ansible add lines to file with split variable

I made a UI that I use to configure our servers. I put the new IP's or servernames into a txt field and have ansbible playbooks ran on them depending on the type of server it is instead of using an ...
1
vote
1answer
92 views

Ansible - items list from a variable list defined from inventory hostname

I have a variable named "bonding" in my host_vars - this is a list of network interfaces to be aggregated into bond0 interface. These values are defined in the inventory, and they are correctly listed ...
2
votes
1answer
20 views

Anible vars in inventories directory no applying

I am using a role (zaxos.lvm-ansible-role) to manage lvms on a few hosts. Initially I had my vars for the lvm under host_vars/server.yaml which works. Here is the working layout ├── filter_plugins ...
0
votes
2answers
40 views

Looping over list data in Ansible playbooks

In my quest to automate some of our network environment I would like to know how you could loop over different items in nested lists. To make it more clear I will explain what I want to do using my ...
0
votes
1answer
46 views

How to loop over my inventory list in jinja2 (currently using a template in my playbook)

I'm attempting to get the output of some show commands on some network devices. My current code loops over the same host 4 times instead of over all 4 hosts in my inventory file. How do I rectify this ...
0
votes
0answers
22 views

Passing a yaml variable from Extra Variables in Ansible tower to my bash inventory script

Ansible Tower (noob) I created a bash script in "inventory scripts". In my template I prompt on launch so I can change a variable (a three character ID) before execution My question is: How can I ...
0
votes
2answers
42 views

Printing objects without ansible_host

I'm trying to use jq to process JSON from the VMware Ansible inventory module so I can produce a list of objects (VMs) that don't have ansible_host defined. The closest I've been able to get is: { ...
0
votes
1answer
63 views

Using nested inventory lists in Ansible playbooks

As I am automating some of our network environment with the help of Ansible I would like to start making use of nested inventory/variable files. This foremost to keep everything tidy and well-arranged....
1
vote
1answer
62 views

Updating /etc/ansible/hosts with ansible

I want to update just one entry from inventory file /etc/ansible/hosts depending on some conditions (e.g. change in network properties). From this snippet of my inventory file, I would like to update ...
1
vote
1answer
24 views

Assign ssh users depends on host names mentioned in host file in Ansible

My Host file is defined as below. [groupname] server1 server2 server3 Each server from the above list have different SSH user to logins. In my playbook I am setting up the user depending on the ...
1
vote
1answer
13 views

Ansible fetch host IP from another group based on defined variable

I would like to fetch IP of a host from another group in inventory file based on variable name. Example inventory file: [master] master-0.example.io master-1.example.io master-2.example.io [replica]...
1
vote
0answers
50 views

Ansible: Can't set variable for sequential execution

I'm trying to build a playbook with rolling update use case (Sequential Execution) with the serial element. Since I have to use the serial value in multiple places in the playbook, I wanted to use it ...
1
vote
1answer
40 views

AWS/Ansible - How to access facts across roles/hosts from host defined in dynamic-inventory?

I am currently setting up a number of Ansible roles to setup a Kubernetes cluster. So far I have a role to provision idempotent EC2s (1x Master / 2x Worker) and subsequent roles to setup these master/...
1
vote
2answers
100 views

Ansible not overriding default vars

I have the following variables defined in role/defaults/main.yml: jvm_heap_size_max: 1024 jvm_heap_size_min: "{{ (jvm_heap_size_max * 0.5)|int|abs }}" My group_vars folder looks like this: ├── ...
0
votes
1answer
57 views

Ansible ssh connection fails with “Failed to login: Connection refused”

I have one esxi host. I need to get some data for which i need to have linux on the same host. So i reboot the host with liveboot with rhel7.4. Perform some operations and then again i reboot the host ...
0
votes
1answer
26 views

Passing Custom Var to the script in Audit

I'm writing a dynamic inventory script to work with Ansible Playbook. I'm looking for a way to pass a custom var extracted from the inventory script to use in a task in my playbook. My inventory from ...
0
votes
0answers
79 views

Trying to ping windows host uing ansible, but not successfull

I am trying to ping windows host from using ansible, but unable to ping. getting below errors: fatal: [localhost]: FAILED! => { "changed": false, "module_stderr": "#< CLIXML\r\n<...
0
votes
1answer
33 views

How to get host alias name in a variable?

In our ansible scripts we are having a variable set_fact: Obj_prefix=smoke-{{ ansible_host }} this fact obj_prefix long as our ansible host name is like machinename.labname.domainname . In our ...