-
Notifications
You must be signed in to change notification settings - Fork 0
/
sapfront_create_users.yml
51 lines (44 loc) · 1.25 KB
/
sapfront_create_users.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
- name: Add SAPADM group and USER
hosts: sap_frontend
gather_facts: false
become: yes
vars_prompt:
- name: "username"
prompt: "Plz enter user name"
private: no
default: "avner"
- name: "uid"
prompt: "Plz enter user uid number"
private: no
default: "1041"
- name: "pass"
prompt: "Plz enter initial password for user"
private: yes
default: ""
tasks:
- name: Ensure group "sapadm" exists with group id 1001
group:
name: sapadm
gid: 1001
state: present
- name: Create/Modify {{username}} with User ID {{uid}}; group sapadm 1001
user:
name: '{{username}}'
comment: some comment
uid: '{{uid}}'
group: sapadm
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
password: "{{pass| password_hash('sha512') }}"
update_password: on_create
- name: collect 'cat /etc/passwd | grep {{username}}'
shell: 'cat /etc/passwd | grep {{username}}:'
args:
executable: /bin/bash
register: result
- name: print 'cat /etc/passwd | grep {{username}}:'
debug:
var: result.stdout_lines
verbosity: 0
- local_action: "copy content='{{ result.stdout_lines }}' dest=check_user_results.txt"