Use this tag for questions regarding Ansible facts - values discovered by the setup module of Ansible or pulled from ohai/facter.
Questions tagged [ansible-facts]
768 questions
-1
votes
1 answer
How do I add individual server with individual user in ansible playbook?
For example we have 5 servers and 5 users
We need to add individual user to
individual server through Ansible playbook.
I have written playbook but it is adding all 5 users in all 5 servers.
But I need to add user1 in server1 and user 2 in server2…
-1
votes
1 answer
how can we schedule a task to update patching in windows servers through ansible?
we have close to 6 thousand windows servers every month to update them to patching and certain products .we are looking for a solution to automate there updation through ansible without using ansible tower/awx. Please can anyone suggest how this can…
-1
votes
1 answer
Ansible - How to access debug output from register?
**Hello.
Please help me with below.
I want to access '3.21.228.186' of
"public_ip": "3.21.228.186".
What should be debug-var variable ?
##########Full output:
How can I solve this ?
> ok: [localhost] => {
>
> "start_AWS": {
>
> …

Srivi
- 211
- 1
- 4
- 11
-1
votes
1 answer
How to add variables with command line in ansible?
i have to playbook for tower-cli command, which will create credentials with custom credentials type.
- name: Create a valid SCM credential from a private_key file
shell:
cmd: tower-cli credential create --organization "Default" --name…

Mathan
- 1
- 2
-1
votes
1 answer
Passing Shell command in ansible based on condition
I m very new to ansible and facing some difficulty in this
I have to pass the full shell command based on some condition in ansible
I tried to set facts but i'm not able to execute the shell and getting error as variable not defined
msg": "The task…

Raj024
- 13
- 1
- 4
-1
votes
1 answer
how to get specific attribute value from stdout json in ansible
instance_tags.stdout output would look like
Expected output of fallowing snippet is App Server-Development
- name: get instance tags
win_shell: aws ec2 --region us-east-1 describe-tags \ --filters "Name=resource-id,Values={{instance_id}}"
…

Pavan Kumar Chithari
- 11
- 4
-1
votes
1 answer
add_host - add all host
I made a playbook that devid the hosts to windows and linux groups. this is the script (for now its just Linux and print the items that in the group):
---
- name: firstPlaybook
hosts: all
gather_facts: true
tasks:
- name: Linux Group
…

user7431944
- 9
- 2
-1
votes
2 answers
Ansible role assert fails on vars built on count of hosts in inventory groups
Team,
Using roles not directly playbook.
I am trying count the number of hosts in inventory under certain groups and then assert that value. but am getting undefined value response in output. Also, is there any better way to do this?
- name:…

AhmFM
- 1,552
- 3
- 23
- 53
-1
votes
2 answers
how to set ansible fact from an array with whitespace
i am trying to set facts from a json array, since the key contains space i am unable to parse, can someone help me here,
i want to set fact as "name": "IN-FG-04" when "vdom": "vdom-shop"
Please see my sample playbook entry
- name: Iterate JSON
…

athi
- 41
- 6
-1
votes
1 answer
need to send mail using attachment and password encryption in ansible
I am facing issue with by below playbook on 2 scenarios
1) How to send mails using ansible without defining the password of the account. using SMTP username and password now in the play to send mail. but is there any alternate way to avoid…

saran
- 139
- 1
- 2
- 12
-1
votes
1 answer
mysql_replication_role is default or user defined? If User defined, How can I set it in my playbook?
In Ansible to install MySQL, I used a property in my config like the below code
{% if mysql_replication_master %}
# Replication
server-id = {{ mysql_server_id }}
{% if mysql_replication_role == 'master' %}
log_bin = mysql-bin
log-bin-index =…

Vasantha Kumar G
- 33
- 9
-1
votes
1 answer
error while setting a fact or debug a webpage after registering this webpage in the get_uri module in Ansible
I have a problem every time while setting a fact for a registered webpage the error is :
u'redirected': False}]}: template error while templating string: unexpected char u'&' at 1238
The Playbook like:
- name: check webpage
uri:
url:…

yousef
- 91
- 1
- 1
- 5
-1
votes
1 answer
Accessing ansible variable properties with property names as other variables
I have the following code:
- name: "Get output from ec2.py"
shell: python convinventory/ec2.py
register: ec2_py_output
- set_fact:
EC2_MY_AP_HOST: "{{(ec2_py_output.stdout | from_json ).myIPs[0]}}"
- set_fact:
EC2_MY_AP_DATA: "{{…

kosta
- 4,302
- 10
- 50
- 104
-1
votes
1 answer
Searching Ansible debug messages for a string
I'm trying to find all the up interfaces on a switch, by looking at the results of some output from nxos_facts:
- name: get nxos facts via nxapi
nxos_facts:
provider: "{{ provider['nxapi'] }}"
gather_subset:
- "interfaces"
…

user1039417
- 109
- 9
-1
votes
1 answer
Digging down an Ansible fact
I have a playbook
---
- hosts: all
gather_facts: True
tasks:
- action: debug msg="time = {{ ansible_date_time }}"
Which returns the full json representation for each machine.
How do I further filter that within the playbook such that I only…

Paul J
- 69
- 2
- 6