-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path11_hostname_users.play.yml
48 lines (42 loc) · 1.32 KB
/
11_hostname_users.play.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
- name: Configuration of users and hosts
hosts: archlinux
vars:
ansible_become: yes
tasks:
- name: Set hostname
# not ansible.builtin.hostname, since the systemd way will escape the chroot
ansible.builtin.lineinfile:
path: /etc/hostname
create: true
regexp: '.*'
line: '{{hostname}}'
tags: hostname
- name: Set timezone to UTC
ansible.builtin.file:
src: /usr/share/zoneinfo/UTC
dest: /etc/localtime
state: link
- name: root password root
ansible.builtin.user:
name: root
password: $6$HNlif6QMOj3xDzLB$i.qeh2i4Jn5oVMVZjxPS.1aeCkc6gK1q0IH6hrbMDhDyn2OSOfJ.bsOwR2qOyCo55CWyQ8KGBkgi9.5zEJziL/
# echo "root" | mkpasswd --method=sha-512 -s
- name: Create main user
ansible.builtin.user:
user: '{{username}}'
groups: wheel, uucp, video
tags: user
- name: Install authorized_key from localhost
ansible.posix.authorized_key:
user: '{{username}}'
key: "{{ lookup('file', ssh_key_pub) }}"
state: present
register: authorized_keys
tags: user
- name: Remove Arch Linux ARM default user
when: authorized_keys['state'] == 'present'
ansible.builtin.user:
name: alarm
state: absent
remove: yes
tags: user