Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
da458bbf
Commit
da458bbf
authored
Oct 05, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added way to display inventory vars for host to faq + some minor fixes/edits
parent
323012be
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
docsite/rst/faq.rst
+11
-2
No files found.
docsite/rst/faq.rst
View file @
da458bbf
...
...
@@ -154,7 +154,15 @@ Ansible by default gathers "facts" about the machines under management, and thes
ansible -m setup hostname
This will print out a dictionary of all of the facts that are available for that particular host.
This will print out a dictionary of all of the facts that are available for that particular host. You might want to pipe the output to a pager.
.. _browse_inventory_vars:
How do I see all the inventory vars defined for my host?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
You can see the resulting vars you define in inventory running the following command::
ansible -m debug -a "var=hostvars['hostname']" localhost
.. _host_loops:
...
...
@@ -208,7 +216,7 @@ Anyway, here's the trick::
{{ hostvars[groups['webservers'][0]]['ansible_eth0']['ipv4']['address'] }}
Notice how we're pulling out the hostname of the first machine of the webservers group. If you are doing this in a template, you
could use the Jinja2 '#set' directive to simplify this, or in a playbook, you could also use set_fact:
could use the Jinja2 '#set' directive to simplify this, or in a playbook, you could also use set_fact:
:
- set_fact: headnode={{ groups[['webservers'][0]] }}
...
...
@@ -310,6 +318,7 @@ The no_log attribute can also apply to an entire play::
Though this will make the play somewhat difficult to debug. It's recommended that this
be applied to single tasks only, once a playbook is completed.
I don't see my question here
++++++++++++++++++++++++++++
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment