-
Notifications
You must be signed in to change notification settings - Fork 0
/
91-omv.yml
57 lines (50 loc) · 1.75 KB
/
91-omv.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
54
55
56
57
---
# file: 91-omv.yml
# As this is the bootstrap script, it should be run WITHOUT firstrun.sh!!
- name: Bootstrap Friendly-Elec
hosts:
# this means: specify on commandline, for instance: ansible-playbook 99-nuke.yml -e 'nuke=ams-dmz-jump'
- ssdnas
remote_user: root
vars:
ansible_password: fa
tasks:
- name: Read remote_user from ansible.cfg
ansible.builtin.set_fact:
cfg_rem_user: "{{ lookup('ansible.builtin.ini', 'remote_user section=defaults file=ansible.cfg') }}"
- name: Remove the pi user
ansible.builtin.user:
name: pi
state: absent
remove: true
- name: Create the ansible user
ansible.builtin.user:
name: "{{ cfg_rem_user }}"
create_home: true
skeleton: /etc/skel
groups: sudo
shell: /bin/bash
- name: Set the primary key for the unprivileged user, removing any others
ansible.posix.authorized_key:
user: "{{ cfg_rem_user }}"
key: "{{ lookup('file', '../home/ssh-keys/{{ cfg_rem_user }}/{{ cfg_rem_user }}-key.pub') }}"
state: present
exclusive: true
- name: Set passwordless sudo for the unprivileged user
ansible.builtin.shell: |
touch /etc/sudoers.d/ansible
/bin/sh -c "echo 'ansible ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/ansible"
chmod 440 /etc/sudoers.d/ansible
changed_when: true
- name: Set the package locations to EU-based repositories (because, well, reasons)
ansible.builtin.template:
src: ./debian-preseed/sources.list
dest: /etc/apt/sources.list
owner: root
group: root
mode: '0644'
force: true
- name: Change the root password
ansible.builtin.user:
name: root
password: '!'