-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_setup-new.yml
executable file
·184 lines (165 loc) · 4.75 KB
/
1_setup-new.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
---
- name: Setup sssd
hosts: ipaclients
collections:
- freeipa.ansible_freeipa
become: true
roles:
- ipaclient
- name: Setup users and groups
hosts: all
become: yes
roles:
- users
- name: Install zsh
hosts: all
become: yes
roles:
- role: gantsign.oh-my-zsh
become: yes
users:
- username: '{{ vault_ansible_user }}'
- name: Apply common configuration to all nodes
hosts: all
become: yes
roles:
- common
- ansible-ssh-hardening
vars:
ssh_banner: true
- name: Install Wireguard client
hosts: docker-external
become: yes
no_log: false
roles:
- githubixx.ansible_role_wireguard
- name: Install Print server
hosts: printing
become: yes
roles:
- cups
vars:
cups_lpadmin_users:
- '{{ vault_ansible_user }}'
- name: Install user 'docker' for 'docker' groups
hosts: docker
become: yes
tasks:
- name: Ensure group "docker" exists with correct gid
ansible.builtin.group:
name: docker
state: present
gid: "{{docker_group}}"
- name: Add the user 'docker' with a specific uid and a primary group of 'docker'
ansible.builtin.user:
name: docker
comment: Docker user
uid: '{{docker_user}}'
group: docker
shell: /usr/sbin/nologin
groups: render,docker,users
append: yes
password: '{{ vault_ansible_user_password }}'
- name: Add user '{{ vault_ansible_user }}' to 'docker' group
ansible.builtin.user:
name: '{{ vault_ansible_user }}'
groups: docker
append: yes
- name: Install aptitude using apt
apt: name=aptitude state=latest update_cache=yes force_apt_get=yes
- name: Install required system packages
apt: name={{ item }} state=latest update_cache=yes
loop: [ 'apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common', 'python3-pip', 'virtualenv', 'python3-setuptools']
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable
state: present
- name: Update apt and install docker-ce
apt: update_cache=yes name=docker-ce state=latest
- name: Install Docker Module for Python
pip:
name: docker
- name: Ensure defaults networks exist
community.docker.docker_network:
name: proxy
- name: Mount the network data for docker
hosts: docker-internal
become: yes
tasks:
- name: Ensure data directory exists
file:
path: /mnt/data
state: directory
owner: '{{docker_user}}'
group: "{{users_group}}"
mode: g+rwx
- name: Mount up data device by UUID
ansible.posix.mount:
path: /mnt/data
src: UUID=8fa04e3d-2b67-4abf-b0d7-142ebf3ee140
fstype: ext4
opts: nofail,defaults,rw
state: present
- name: Ensure docker directory exists
file:
path: /mnt/docker
state: directory
- name: Mount up data device by UUID
ansible.posix.mount:
path: /mnt/docker
src: UUID=f6f96590-9da3-4d7b-82cf-b84d0d8a6ba9
fstype: ext4
opts: nofail,_netdev,defaults,rw
state: present
- name: Ensure data-1 directory exists
file:
path: /mnt/data-1
state: directory
owner: '{{docker_user}}'
group: "{{users_group}}"
mode: g+rwx
- name: Mount up data-1 device by UUID
ansible.posix.mount:
path: /mnt/data-1
src: UUID=617376ee-dc97-4f9e-97ac-7489a285fd10
fstype: ext4
opts: nofail,_netdev,defaults,rw
state: present
# For each new host, you MUST run restic init --repo /mnt/backup/servers/{{fqdn}} BEFORE running the task
- name: Setup shared directories for local servers
hosts: local
become: yes
roles:
- local-srv
vars:
idmapd_domain: '{{domain_tld}}'
# - name: Remove the user 'ubuntu'
# hosts: all
# become: yes
# tasks:
# # - debug:
# # msg: |
# # ansible_user: {{ ansible_user | d('unset') }};
# # remote_user: {{ remote_user | d('unset') }}
# - name: Change remote user
# set_fact:
# current_user: '{{ vault_ansible_user }}'
# ansible_user: '{{ vault_ansible_user }}'
# remote_user: '{{ vault_ansible_user }}'
# - name: Remove the user 'ubuntu'
# user:
# name: ubuntu
# state: absent
# remove: yes
# - name: Playbook to configure IPA server
# hosts: ipaserver
# become: true
# collections:
# - freeipa.ansible_freeipa
# tasks:
# - import_role:
# name: ipaserver