summaryrefslogtreecommitdiff
path: root/ansible-practice/system/06-playbook-print-group-vars.yml
diff options
context:
space:
mode:
authorboom2 <blizzack@blizzack.com>2023-12-08 14:12:33 -0500
committerboom2 <blizzack@blizzack.com>2023-12-08 14:12:33 -0500
commitd8a7729358a2fd3b911022e45d0197fda3e5da94 (patch)
treef75d69bcd7b08a9bebf325c037e4557c61a958e2 /ansible-practice/system/06-playbook-print-group-vars.yml
parent2fd6a845dfe9ed6b3189c247928dc87d8f76d01a (diff)
- add exeriments for:
- roles - variables - inventory changes - config changes
Diffstat (limited to 'ansible-practice/system/06-playbook-print-group-vars.yml')
-rw-r--r--ansible-practice/system/06-playbook-print-group-vars.yml44
1 files changed, 44 insertions, 0 deletions
diff --git a/ansible-practice/system/06-playbook-print-group-vars.yml b/ansible-practice/system/06-playbook-print-group-vars.yml
new file mode 100644
index 0000000..850bea2
--- /dev/null
+++ b/ansible-practice/system/06-playbook-print-group-vars.yml
@@ -0,0 +1,44 @@
+
+# https://stackoverflow.com/questions/53253879/ansible-vars-files-vs-include-vars
+# https://docs.ansible.com/ansible/2.7/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable
+
+# https://www.middlewareinventory.com/blog/run-ansible-playbook-locally/
+# https://nixzie.com/run-ansible-playbook-locally/#Run_Ansible_Playbook_Locally_Using_Local_Action
+# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_delegation.html#delegating-facts
+# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html
+# https://docs.ansible.com/ansible-core/2.15/reference_appendices/interpreter_discovery.html
+
+---
+- name: "06"
+ hosts: localhost
+# hosts: "*"
+ tasks:
+ - name: Print the gateway for each host when defined
+ ansible.builtin.debug:
+ msg: System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}
+ when: ansible_default_ipv4.gateway is defined
+
+ - name: Print the ansible python interpreter
+ ansible.builtin.debug:
+ msg:
+ - "ansible_playbook_python = {{ ansible_playbook_python }}"
+# - "ansible_python_interpreter = {{ ansible_python_interpreter }}"
+
+ - name: Print the ansible python interpreter - for the localhost
+ ansible.builtin.debug:
+ msg:
+ - "ansible_playbook_python = {{ ansible_playbook_python }}"
+ - "ansible_host = {{ ansible_host }}"
+# - "ansible_python_interpreter = {{ ansible_python_interpreter }}"
+ delegate_to: localhost
+ run_once: true
+
+ - name: Print the ansible python interpreter - using 'local_action'
+ local_action:
+ module: ansible.builtin.debug
+ var: ansible_playbook_python
+ run_once: true
+
+ - name: Print the group variable
+ ansible.builtin.debug:
+ msg: prefix variable = {{ prefix_dir }}