Skip to content

Commit 794d20b

Browse files
committed
adjust test.yml
1 parent a6c9d50 commit 794d20b

File tree

1 file changed

+26
-44
lines changed

1 file changed

+26
-44
lines changed

test.yml

+26-44
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,53 @@
11
---
22
- name: "Playbook to test various variables"
33
hosts: all
4-
#become: false
54
become: true
65
become_method: sudo
76
gather_facts: true
8-
# vars_files example
9-
#vars_files:
10-
#- "./tf_ansible_vars/ansible_vars.yml"
11-
tasks:
12-
- name: group_names
13-
debug:
14-
msg: "{{ group_names }}"
15-
16-
- name: ansible_hostname
17-
debug:
18-
msg: "{{ ansible_hostname }}"
19-
20-
- name: ansible_user
21-
debug:
22-
msg: "{{ ansible_user }}"
237

24-
- name: playbook_dir
25-
debug:
26-
msg: "{{ playbook_dir }}"
27-
28-
- name: ansible_env['HOME']
29-
debug:
30-
msg: "{{ ansible_env['HOME'] }}"
31-
32-
- name: ansible_os_family
8+
tasks:
9+
- name: host information
3310
debug:
34-
msg: "{{ ansible_os_family }}"
11+
msg: |
12+
ansible_host: {{ ansible_host }}
13+
ansible_hostname: {{ ansible_hostname }}
14+
playbook_dir: {{ playbook_dir }}
15+
group_names: {{ group_names }}
16+
ansible_python_version: {{ ansible_python_version }}
3517
36-
- name: ansible_env['PWD']
18+
- name: os information
3719
debug:
38-
msg: "{{ ansible_env['PWD'] }}"
20+
msg: |
21+
ansible_os_family: {{ ansible_os_family }}
22+
ansible_distribution: {{ ansible_distribution }}
23+
ansible_distribution_version: {{ ansible_distribution_version }}
3924
40-
- name: ansible_default_ipv4[address]
25+
- name: network information
4126
debug:
4227
msg: |
4328
Primary Interface: {{ ansible_default_ipv4.interface }}
4429
IP Address: {{ ansible_default_ipv4.address }}
4530
Subnet: {{ ansible_default_ipv4.network }}
4631
Netmask: {{ ansible_default_ipv4.netmask }}
47-
48-
- name: ansible_env['USER']
49-
debug:
50-
var: ansible_env['USER']
51-
52-
- name: ansible_env['SUDO_USER']
53-
debug:
54-
var: ansible_env['SUDO_USER']
55-
56-
- name: Distribution version
57-
debug:
58-
var: "{{ ansible_distribution_version }}"
32+
All Interfaces: {{ ansible_interfaces }}
5933
6034
- name: Get user's primary group name
6135
command: "id -gn {{ ansible_env.SUDO_USER | default(ansible_user_id) }}"
6236
register: primary_group
6337
changed_when: false
6438

65-
- name: Get user's primary group name
39+
- name: Get user's primary group name - set fact (custom var)
6640
set_fact:
6741
user_primary_group: "{{ primary_group.stdout }}"
6842

69-
- name: Display user's primary group name
43+
- name: user information
7044
debug:
71-
var: user_primary_group
45+
msg: |
46+
ansible_env['USER']: {{ ansible_env['USER'] }}
47+
ansible_env['SUDO_USER']: {{ ansible_env['SUDO_USER'] }}
48+
ansible_env['SHELL']: {{ ansible_env['SHELL'] }}
49+
ansible_env['PWD']: {{ ansible_env['PWD'] }}
50+
ansible_env['HOME']: {{ ansible_env['HOME'] }}
51+
ansible_user: {{ ansible_user }}
52+
ansible_user_id: {{ ansible_user_id }}
53+
ansible_user primary group (custom var): {{ user_primary_group }}

0 commit comments

Comments
 (0)