-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.yml
53 lines (47 loc) · 1.81 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- name: "Playbook to test various variables"
hosts: all
become: true
become_method: sudo
gather_facts: true
tasks:
- name: host information
debug:
msg: |
ansible_host: {{ ansible_host }}
ansible_hostname: {{ ansible_hostname }}
playbook_dir: {{ playbook_dir }}
group_names: {{ group_names }}
ansible_python_version: {{ ansible_python_version }}
- name: os information
debug:
msg: |
ansible_os_family: {{ ansible_os_family }}
ansible_distribution: {{ ansible_distribution }}
ansible_distribution_version: {{ ansible_distribution_version }}
- name: network information
debug:
msg: |
Primary Interface: {{ ansible_default_ipv4.interface }}
IP Address: {{ ansible_default_ipv4.address }}
Subnet: {{ ansible_default_ipv4.network }}
Netmask: {{ ansible_default_ipv4.netmask }}
All Interfaces: {{ ansible_interfaces }}
- name: Get user's primary group name
command: "id -gn {{ ansible_env.SUDO_USER | default(ansible_user_id) }}"
register: primary_group
changed_when: false
- name: Get user's primary group name - set fact (custom var)
set_fact:
user_primary_group: "{{ primary_group.stdout }}"
- name: user information
debug:
msg: |
ansible_env['USER']: {{ ansible_env['USER'] }}
ansible_env['SUDO_USER']: {{ ansible_env['SUDO_USER'] }}
ansible_env['SHELL']: {{ ansible_env['SHELL'] }}
ansible_env['PWD']: {{ ansible_env['PWD'] }}
ansible_env['HOME']: {{ ansible_env['HOME'] }}
ansible_user: {{ ansible_user }}
ansible_user_id: {{ ansible_user_id }}
ansible_user primary group (custom var): {{ user_primary_group }}