Questions tagged [ansible-facts]

Use this tag for questions regarding Ansible facts - values discovered by the setup module of Ansible or pulled from ohai/facter.

768 questions
0
votes
1 answer

Ansible: Access facts set by set_fact

I need to be able to set variables using tasks in Ansible. I use set_fact for this, but cannot seem to access the fact I set with this. What is wrong with the code below: - name: kludge1 set_fact: fake_y = "{{ [] }}" - name: Loop debug: …
jdoestackoverflow
  • 607
  • 1
  • 7
  • 15
0
votes
1 answer

Finding the volume mount points for a list of docker volumes in ansible

It's unfortunate that there is no current API that would allow us to work with docker volumes. At the moment if I need to copy data into a docker volume (NB: not a docker container) I must first ensure that some container can access the volume, and…
DMCoding
  • 1,167
  • 2
  • 15
  • 30
0
votes
1 answer

Ansible fact can't reference as my host/group variable

If I'm to declare following variable under my "host_vars/host_name" or "group_vars/group_name" folders - I'll end up with undefined variable. At the same time if I'm to declare the same in my Inventory file under any of my ":var" group variables I…
0
votes
2 answers

hostvars for localhost (Ansible master) only grabbing a few facts

I have this line in my playbook: - debug: msg="{{ hostvars['127.0.0.1'] }}" and for some reason it only grabs a handful of facts, primarily around setup of the master. - hosts: mfg-pc:master become: yes become_method: sudo gather_facts: True …
EnemyBagJones
  • 952
  • 1
  • 13
  • 25
0
votes
1 answer

Ansible to store variable facts

Using Ansible here, I'm gathering facts about a container: - name: start my container lxd_container: name: vm_srv1 state: started register: st - debug: msg="{{ st.addresses }}" Running the playbook produces the…
Deano
  • 11,582
  • 18
  • 69
  • 119
0
votes
1 answer

Ansible rds 'facts' doesn't return me the ARN

I need to find the ARN for my Db instance using facts keyword provided at RDS Module. The following is a basic play: - name: Get The RDS Facts from AWS rds: command: facts region: '{{ aws_region }}' instance_name: '{{…
Kittystone
  • 661
  • 3
  • 9
  • 28
0
votes
1 answer

Override Ansible facts similar to Puppet and Facter override

NOTE: Part of Puppet to Ansible migration evaluation. Ansible noob. CentOS 7 returns operatingsystemrelease (puppet) or ansible_distribution_version (ansible) as 7.2.1511 instead of just 7.2. So in puppet we use the following hack. # Hack for…
MavWolverine
  • 846
  • 1
  • 9
  • 24
0
votes
4 answers

Force Ansible to gather facts from group

I want to force Ansible to gather facts about hosts inside playbook (to use those data inside role) regardless --limit, but don't know how. I have playbook like this: - hosts: postgres_access tasks: - name: Gathering info action: setup -…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
0
votes
1 answer

How can I use ansible facts in order to skip execution of some sections?

I want to speed-up ansible playbook execution by avoiding to call some sections that do not have to be called more often than once a day or so. I know that facts are supposed to allow us to implement this but it seems almost impossible to find some…
sorin
  • 161,544
  • 178
  • 535
  • 806
0
votes
1 answer

How to get facts at each command in Ansible

Ansible get facts only at start. But i need check facts at each commands. For example: I need create a directory, after that i need put file to this directory. But ansible get fact 'dir doesn't exist' at start, create dir and at next step fact still…
ITJunkie
  • 3
  • 3
0
votes
1 answer

Can Ansible automatically check state of node and bring it back to desired state if it has become misaligned?

In Puppet, a node agent will check in with the Master every so often and send facts about the node. The Master will then check these facts are what it should be and if they have become misaligned will revert them to the desired state. For instance,…
Zuriar
  • 11,096
  • 20
  • 57
  • 92
-1
votes
0 answers

Replace line in ansible playbook with override

I am trying to write one playbook that checks for sudoers syntax and logs the PASS or FAIL result in a file. When I run it initially , it logs PASS message saying everything is fine. But when I intentionally insert wrong syntax in the file , it…
isilia
  • 379
  • 1
  • 11
-1
votes
2 answers

In Ansible, how to exit with sucess if any host is unreachable (without using ignore_unreachable)

I have the following playbook to get the first reachable host. --- - hosts: all gather_facts: yes ignore_unreachable: yes tasks: - name: Get the first good host in the group vars: query: "[?ansible_facts!=''].inventory_hostname" …
Dentrax
  • 574
  • 8
  • 22
-1
votes
1 answer

How to pass variable from Ansible 'service_facts'?

Error when passing variable ansible.builtin.set_fact: apache_status: "{{ service_status['ansible_facts']['services']['{{ web_pkg }}.service']['state'] }}" Below working fine - name: Fetch Apache Service ansible.builtin.set_fact: …
UME
  • 323
  • 1
  • 2
  • 7
-1
votes
1 answer

Capture variable from Ansible output

We want to capture variables from Ansible output. We have a bulk dns record and wanted to capture FQDN and IP address from output but were unable to display it. Tasks are below: - name: Run DNS Lookup command: dig +short "{{ item }}" …
SJS
  • 27
  • 5