Questions tagged [ansible-inventory]
Use this tag if a question is about ansible-inventory
22
questions
1
vote
0
answers
20
views
ansible_become has no effect despite the ability to execute sudo on GCP hosts
Say I want to execute the following command on target hosts (deployed on GCP): ansible all -a "head -1 /etc/shadow".
The command demands the root access. With the default Ansible ...
1
vote
4
answers
179
views
What is a good strategy to prevent Ansible playbook runs against the wrong hosts? [duplicate]
It is too easy to run playbooks on the wrong hosts in Ansible
I know the best practice would be to use --limit to make sure you can not select the wrong host. I do not trust --limit to ensure Ansible ...
1
vote
1
answer
63
views
Creating a hostgroup from a super-set of hosts
I have two host files with different hosts, hostGroups and super-set in each file like below.
/ets/hostFiles/TestBoxes
[TestBox:children]
groupA
groupB
[groupA]
...
...
[groupB]
...
...
/ets/...
2
votes
1
answer
138
views
Ansible: How to run ad-hoc command with multiple environnements?
Given the following architecture:
├── ansible.cfg
├── hosts
│ ├── production
│ └── staging
├── production
│ ├── group_vars
│ │ ├── all.yml
│ │ ├── mygroup.yml
│ │ └── mygroup2.yml
│ ...
1
vote
1
answer
174
views
Ansible: Does the `hosts: all` pattern in a play only match hosts specified in inventory, or does it also match playbook `add_host` hosts?
I know "all" doesn't match the implicit localhost; the title succinctly expresses my question.
Motivation: I have a playbook that needs to be run on cloud hosts generated dynamically and ...
0
votes
1
answer
918
views
ansible playbook cannot apply, giving host unreachable error
I'm completely new to ansible and I'm having a hard time with it. I have an inventory.yml file which is as the following:
EDIT: changed my inventory.yml now looks as follows
inventory.yml:
[master]
...
1
vote
0
answers
1k
views
Ansible/AWS dynamic inventory -- How to create groups based on tags?
I am trying to create custom groups, based on tags. I am using this doc as a reference: https://docs.ansible.com/ansible/latest/plugins/inventory.html#inventory-plugins
As a baseline, in my aws_ec2....
2
votes
2
answers
1k
views
Ansible - merging inventories to share variables across?
Is it possible to merge inventories so I can share variables across them? Let's say I have two inventory files. Inventory A and Inventory B. They are both in a directory called inventories.
Variables ...
1
vote
1
answer
944
views
Ansible dynamic inventory using AWS plugin -- how to obtain internal DNS records or private IP?
Seeking help from those who've worked with dynamic inventory in Ansible.
I have Ansible set up with the aws_ec2 plugin (not using the python script as it's been too problematic). Currently, I'm only ...
6
votes
1
answer
20k
views
ansible error: skipping: no hosts matched
I've tried a few variations on running ansible locally as a test case:
nicholas $
nicholas $ ls
ansible.cfg ansible.cfg.orig first_playbook.yml inventory.txt playbook.yml
nicholas $
nicholas $ ...
0
votes
2
answers
2k
views
network ansible command error: "msg": "network os centos is not supported"
How do I get the ansible config for rolly below?
remote:
[nsaunders@rolly ~]$
[nsaunders@rolly ~]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: ...
3
votes
2
answers
460
views
Can we use Ansible for monitoring configuration?
I understand how Ansible works and what it is used for.
However, I was wondering if there is a way or feature (in open-source or enterprise edition) in Ansible using which, we can make sure that the ...
5
votes
2
answers
12k
views
Custom inventory file failing to parse properly
I've got the following production inventory file (playbooks/production.yaml) for Ansible:
all:
children:
control:
moriarty.server.com
toby.server.com
managed:
sherlock....
1
vote
1
answer
40
views
Ansible: Backing up variable value doesn't work as expected
Attempting to save a variable's value for backup before modifying it doesn't work.
I have the following inventory file (note the custom ansible_port and user):
all:
hosts:
test:
...
1
vote
0
answers
89
views
Per machine credentials for privileges escalation using AWX [duplicate]
I have an inventory with a lot of hosts in it using the same credentials, but one host needs a different approach. For the ssh connection a different user is used, after the connection is established, ...
0
votes
1
answer
1k
views
Ansible - stop when host is success, exit with IP
Basically, my use case is that I want to run on list of hosts (group from inventory).
It will run one by one, until it finds machine answer my standards,
when it find the one with free RAM as I say e....
3
votes
1
answer
901
views
Unable to run playbooks using Ansible best practices layout
I am very new to ansible and I think I am lacking something basic that I am not finding in the examples or on github as to the directory structure and its use.
I have set up my directory structure ...
1
vote
2
answers
867
views
Ansible authorized copy from remote source to remote destination
How to use ansible authorized_key to authorize a ServerA (not the controller machine) to access Server B.
Scenario: Need a playbook to execute from a ansible controller that should append id_rsa.pub ...
2
votes
1
answer
439
views
Can I check whether ansible is on last batch of rolling update (serial: 25%)?
I'm using Ansible to update a pool of EC2 servers with a rolling update, in batches of 25%. In between batches, I'm pausing long enough for the server health checks to start to pass again (since they'...
2
votes
1
answer
1k
views
Ansible YAML inventory - Groups that are allways members of other groups
Situation:
I have a group "webservers" where I put all webservers in. As well as a group "mysqlservers" for the database servers respectively.
Now I do also manage some LAMP servers and I want them ...
1
vote
1
answer
1k
views
How to write logs for certain tasks only?
I am using Ansible and created a Playbook for deployment. I defined log_path in ansible.cfg and now tasks output are going to this log file. I want to send only few task's log into this log file. How ...
8
votes
1
answer
4k
views
How to notate ipv6 addresses in inventory file?
I have a machine, that is accessible via ipv6 only. It is setup for ssh with rsa key. Now I'd like to manage it with ansible. Unfortunately, this is not covered in the inventory documentation.
So I ...