blob: 5b351f1993dcb0ffba7f5f816588aa3638759671 (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
---
- name: format disk
filesystem:
fstype: btrfs
dev: /dev/sda
force: yes
- name: mount disk
mount:
path: /mnt
src: /dev/sda
state: mounted
fstype: btrfs
- name: modify pacman mirrorlist
copy:
src: mirrorlist
dest: /etc/pacman.d/mirrorlist
- name: remove archlinux-keyring conflicting files (1/3)
file:
dest: /usr/share/pacman/keyrings/archlinux-revoked
state: absent
- name: remove archlinux-keyring conflicting files (2/3)
file:
dest: /usr/share/pacman/keyrings/archlinux-trusted
state: absent
- name: remove archlinux-keyring conflicting files (3/3)
file:
dest: /usr/share/pacman/keyrings/archlinux.gpg
state: absent
- name: update archlinux-keyring
pacman:
name: archlinux-keyring
force: yes
state: present
update_cache: yes
- name: pacstrap
command: /usr/bin/pacstrap /mnt base base-devel openssh python grub
- name: genfstab
shell: /usr/bin/genfstab -U -p /mnt > /mnt/etc/fstab
- name: set hostname
shell: /bin/echo {{ arch_hostname }} > /mnt/etc/hostname
- name: Locale conf
copy:
src: locale.conf
dest: /mnt/etc/locale.conf
- name: vconsole
copy:
src: vconsole.conf
dest: /mnt/etc/vconsole.conf
- name: localtime
file:
src: /usr/share/zoneinfo/Europe/Berlin
dest: /mnt/etc/localtime
state: link
- name: resolv.conf
copy:
src: resolv.conf
dest: /mnt/etc/resolv.conf
- name: locale.gen
replace:
dest: /mnt/etc/locale.gen
regexp: "^#de_DE.UTF-8.*$"
replace: "de_DE.UTF-8 UTF-8"
- name: locale-gen
command: /usr/bin/arch-chroot /mnt locale-gen
- name: "grub: generate config"
command: /usr/bin/arch-chroot /mnt /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
- name: "grub: install grub"
command: /usr/bin/arch-chroot /mnt /usr/bin/grub-install /dev/sda
- name: sshd config
copy:
src: sshd_config
dest: /mnt/etc/ssh/sshd_config
- name: add authorized_keys
authorized_key:
key: '{{ item }}'
path: /mnt/root/.ssh/authorized_keys
user: root
with_items: '{{ authorized_keys }}'
- name: enable sshd
command: /usr/bin/arch-chroot /mnt /usr/bin/systemctl enable sshd.service
- name: create network config
template:
dest: /mnt/etc/netctl/ens3
src: ens3.j2
- name: enable network config
command: /usr/bin/arch-chroot /mnt /usr/bin/netctl enable ens3
- name: unmount
mount:
path: /mnt
state: unmounted
- name: reboot
shell: sleep 5 && reboot &
args:
executable: /bin/bash
async: 10
poll: 0
- name: waiting for server to go down
local_action:
module: wait_for
host: "{{ inventory_hostname }}"
port: 22
delay: 1
timeout: 60
state: stopped
- name: waiting for server to come back
local_action:
module: wait_for
host={{ inventory_hostname }}
port=22
delay=1
timeout=60
- name: remove server from local known_hosts file
local_action: shell ssh-keygen -R {{ inventory_hostname }}
ignore_errors: true
|