# \#variables

**URL:** https://forum.ansible.com/tag/variables/312.md?page=1

[Latest](https://forum.ansible.com/latest.md) · [Categories](https://forum.ansible.com/categories.md) · [Tags](https://forum.ansible.com/tags.md)

**Page:** 2

---

## [Using registered variable in a loop](https://forum.ansible.com/t/using-registered-variable-in-a-loop/8806)

<div class="topic-metadata">

**Author:** [@TheSpy0](https://forum.ansible.com/u/TheSpy0)\
**Replies:** 2\
**Last updated:** [September 27, 2024, 3:43am UTC](https://forum.ansible.com/t/using-registered-variable-in-a-loop/8806 "2024-09-27T03:43:06Z")

</div>

I’m trying to configure Molecule to use Azure’s Devtest Lab virtual machines for testing playbooks using the delegated|default driver. The current issue that I’m running into is getting the necessary data from a register…

---

## [Merging multiple (more than 2) dicts, the correct way](https://forum.ansible.com/t/merging-multiple-more-than-2-dicts-the-correct-way/8592)

<div class="topic-metadata">

**Author:** [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Replies:** 1\
**Last updated:** [September 18, 2024, 4:55pm UTC](https://forum.ansible.com/t/merging-multiple-more-than-2-dicts-the-correct-way/8592 "2024-09-18T16:55:21Z")

</div>

So I know that we’re doing this incorrectly. The question is, how can I do this the correct way? I have a windows.yml group variable file that contains a dict that lists the basic software that machines will need: def…

---

## [Strategy for repeated complex logic between hosts](https://forum.ansible.com/t/strategy-for-repeated-complex-logic-between-hosts/7858)

<div class="topic-metadata">

**Author:** [@LoftyGoals](https://forum.ansible.com/u/LoftyGoals)\
**Replies:** 9\
**Last updated:** [August 16, 2024, 7:14pm UTC](https://forum.ansible.com/t/strategy-for-repeated-complex-logic-between-hosts/7858 "2024-08-16T19:14:49Z")

</div>

I’ve found my “when” clauses are getting too complicated. They involve multiple filters and data from multiple hosts. In any other language I would declare intermediate variables but I can’t get that to work in Ansible. …

---

## [Variables precedence in play and task](https://forum.ansible.com/t/variables-precedence-in-play-and-task/7532)

<div class="topic-metadata">

**Author:** [@motorbass](https://forum.ansible.com/u/motorbass)\
**Replies:** 5\
**Last updated:** [August 5, 2024, 4:59pm UTC](https://forum.ansible.com/t/variables-precedence-in-play-and-task/7532 "2024-08-05T16:59:18Z")

</div>

Hi I’m struggling a bit with variables precedences in my play and in a task. I’m using this play, which works great but I’ve add a last task to reboot my windows server BUT i have to use a special account (so a new ans…

---

## [How to use an inventory variable in a lookup of aws secret?](https://forum.ansible.com/t/how-to-use-an-inventory-variable-in-a-lookup-of-aws-secret/7255)

<div class="topic-metadata">

**Author:** [@PB70](https://forum.ansible.com/u/PB70)\
**Replies:** 7\
**Last updated:** [July 16, 2024, 6:19pm UTC](https://forum.ansible.com/t/how-to-use-an-inventory-variable-in-a-lookup-of-aws-secret/7255 "2024-07-16T18:19:21Z")

</div>

I am trying to lookup an aws\_secret using the lookup functionality, but I want the path to the secret I lookup to come from an inventory variable. That way I can have a different secret for each environment (dev, stage,…

---

## [How to do simple vars manipulation?](https://forum.ansible.com/t/how-to-do-simple-vars-manipulation/7094)

<div class="topic-metadata">

**Author:** [@LoftyGoals](https://forum.ansible.com/u/LoftyGoals)\
**Replies:** 3\
**Last updated:** [July 7, 2024, 5:01pm UTC](https://forum.ansible.com/t/how-to-do-simple-vars-manipulation/7094 "2024-07-07T17:01:52Z")

</div>

I’m new to Ansible (like days). I’m working in 9.2/2.16.3 if that matters and can upgrade if that helps. I think I’m trying to do something simple but I can’t get it. I want to write a role that: Accepts a list of path…

---

## [Skip task if the host name does not appear as key in a dict](https://forum.ansible.com/t/skip-task-if-the-host-name-does-not-appear-as-key-in-a-dict/6976)

<div class="topic-metadata">

**Author:** [@wnelis](https://forum.ansible.com/u/wnelis)\
**Replies:** 4\
**Last updated:** [July 4, 2024, 7:05am UTC](https://forum.ansible.com/t/skip-task-if-the-host-name-does-not-appear-as-key-in-a-dict/6976 "2024-07-04T07:05:25Z")

</div>

The use case is to install SSH public keys on a number of servers. The hosts, users and the files containing the public keys are specified in a variable. Using a list of dictionaries it works. As an exercise the variable…

---

## [Ansible Ping from command line not working](https://forum.ansible.com/t/ansible-ping-from-command-line-not-working/6595)

<div class="topic-metadata">

**Author:** [@Evan\_Goulden](https://forum.ansible.com/u/Evan_Goulden)\
**Replies:** 2\
**Last updated:** [June 18, 2024, 9:34am UTC](https://forum.ansible.com/t/ansible-ping-from-command-line-not-working/6595 "2024-06-18T09:34:26Z")

</div>

Hi There, I am new to Ansible so just learning at the moment and have a question regarding variables and how to access them under specific scenarios. A bit of background, I’ve setup a couple of inventory files and split…

---

## [Accessing other hosts facts works in debug task, but not anywhere else](https://forum.ansible.com/t/accessing-other-hosts-facts-works-in-debug-task-but-not-anywhere-else/6098)

<div class="topic-metadata">

**Author:** [@raspbeguy](https://forum.ansible.com/u/raspbeguy)\
**Replies:** 9\
**Last updated:** [May 31, 2024, 3:07pm UTC](https://forum.ansible.com/t/accessing-other-hosts-facts-works-in-debug-task-but-not-anywhere-else/6098 "2024-05-31T15:07:25Z")

</div>

Hello, I have a group of hosts that have to access to each others IP address. I have the following code: - debug: var: hostvars\[item\]\['ansible\_default\_ipv4'\]\['address'\] loop: "{{ groups\[cluster\_name\] | flatten(lev…

---

## [Reference AWX Username](https://forum.ansible.com/t/reference-awx-username/4952)

<div class="topic-metadata">

**Author:** [@Dustin](https://forum.ansible.com/u/Dustin)\
**Replies:** 5\
**Last updated:** [April 25, 2024, 11:46am UTC](https://forum.ansible.com/t/reference-awx-username/4952 "2024-04-25T11:46:51Z")

</div>

In AWX, I’m looking for a way to reference the details of the user who executes a job. Specifically, I want to get either their username or email address. Then, during one of my playbooks that creates records in Servic…

---

## [Is the current strategy visible to tasks?](https://forum.ansible.com/t/is-the-current-strategy-visible-to-tasks/4489)

<div class="topic-metadata">

**Author:** [@utoddl](https://forum.ansible.com/u/utoddl)\
**Replies:** 1\
**Last updated:** [March 21, 2024, 7:10am UTC](https://forum.ansible.com/t/is-the-current-strategy-visible-to-tasks/4489 "2024-03-21T07:10:01Z")

</div>

Is a playbook’s current strategy exposed to tasks, perhaps through some unlisted special variable? I’m running into ansible-lint’s admonition, “run-once\[task\]: Using run\_once may behave differently if strategy is set to…

---

## [Role defaults available in another role's scope](https://forum.ansible.com/t/role-defaults-available-in-another-roles-scope/3975)

<div class="topic-metadata">

**Author:** [@bluppfisk](https://forum.ansible.com/u/bluppfisk)\
**Replies:** 1\
**Last updated:** [February 21, 2024, 2:10pm UTC](https://forum.ansible.com/t/role-defaults-available-in-another-roles-scope/3975 "2024-02-21T14:10:02Z")

</div>

I noticed that defaults specified in one role’s scope become available in a second role’s scope if both roles are part of the same playbook. I wonder why these defaults do not stick to their role scope? Sample: role\_1/…

---

## [Changing the dictionary key names but not values of items in a loop](https://forum.ansible.com/t/changing-the-dictionary-key-names-but-not-values-of-items-in-a-loop/3434)

<div class="topic-metadata">

**Author:** [@JethCalark](https://forum.ansible.com/u/JethCalark)\
**Replies:** 8\
**Last updated:** [January 28, 2024, 11:12pm UTC](https://forum.ansible.com/t/changing-the-dictionary-key-names-but-not-values-of-items-in-a-loop/3434 "2024-01-28T23:12:45Z")

</div>

I have a role for Adguard Home with a task to add DHCP reservations. That task requires a list variable where each item has the same dictionary keys: - name: Add static leases on AdGuard Home ansible.builtin.uri: …

---

## [How add output in a file?](https://forum.ansible.com/t/how-add-output-in-a-file/3172)

<div class="topic-metadata">

**Author:** [@techmush](https://forum.ansible.com/u/techmush)\
**Replies:** 7\
**Last updated:** [January 5, 2024, 7:05pm UTC](https://forum.ansible.com/t/how-add-output-in-a-file/3172 "2024-01-05T19:05:05Z")

</div>

Hi community, I would like to pull a report which contain hostname and selinux mode (enforcing or permissive). I would like to have just these two output in a txt file. I would also like to have both hostname and sedlin…

---

## [Problem with inventory variables after sync with git](https://forum.ansible.com/t/problem-with-inventory-variables-after-sync-with-git/3073)

<div class="topic-metadata">

**Author:** [@dawid.grygrzc](https://forum.ansible.com/u/dawid.grygrzc)\
**Replies:** 2\
**Last updated:** [December 28, 2023, 2:43pm UTC](https://forum.ansible.com/t/problem-with-inventory-variables-after-sync-with-git/3073 "2023-12-28T14:43:50Z")

</div>

Hi all! I have a problem with variables in inventory. I have a project called ‘test’ (gitlab). Option “Update Revision on Launch” has been filled up. I have a source called ‘test-source’. Options “Overwrite|Overwrite …

---

## [How to we use a different ansible\_connection for delegate host](https://forum.ansible.com/t/how-to-we-use-a-different-ansible-connection-for-delegate-host/2725)

<div class="topic-metadata">

**Author:** [@ku1918](https://forum.ansible.com/u/ku1918)\
**Replies:** 5\
**Last updated:** [December 8, 2023, 6:55pm UTC](https://forum.ansible.com/t/how-to-we-use-a-different-ansible-connection-for-delegate-host/2725 "2023-12-08T18:55:16Z")

</div>

Hi all, I am running a playbook against an inventory fo Windows Server. However , there is a specific task I would like to delegate to a specific host but using ssh connection because it is a linux box. How do I achie…

[Previous page](https://forum.ansible.com/tag/variables/312.md?match_all_tags=true&tags%5B%5D=variables)
