Ansible snippets
- Read more about Ansible snippets
- Log in to post comments
# login as user ubuntu, use python3 and relogin as root
- hosts:
- vm1
- vm2
become: yes
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: ubuntu
tasks:
- include: "{{ inventory_hostname }}.yml"
# show user and host
- debug:
msg="{{ ansible_user_id }}@{{ inventory_hostname }}"
# show host groups
- debug:
msg: "{{ group_names }}"
- debug:
var: hostvars[inventory_hostname]
- debug:
msg: "{{ ansible_system_vendor }}"
- debug:
msg: "ansible_default_ipv4["address"]"
- debug:
msg: "{{ vms | length