-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaybook.yml
164 lines (141 loc) · 4.11 KB
/
playbook.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
---
- hosts: server
gather_facts: False
vars:
- service_disabled: [ ]
- service_started: [ ]
- service_restarted: [ ]
pre_tasks:
- name: 'Ensure python'
raw: "sh -c 'test -e /usr/bin/python3 || (apt -yqq update && apt install -yqq python3)'"
args:
warn: false
tags:
- always
- name: 'Installing facts.d'
copy:
src: facts.d
dest: /etc/ansible/
owner: root
mode: u=rwx,g=rx,o=rx
tags:
- always
- name: Gathering facts
setup:
tags:
- always
- name: Lookup traefik_hostname
shell: hostname -s
register: node_hostname_short_output
tags:
- always
- name: "Set fact node_hostname_short = {{ node_hostname_short_output.stdout }}"
set_fact:
node_hostname_short: "{{ node_hostname_short_output.stdout }}"
tags:
- always
- name: "Set fact entrypoint_hostname = {{ traefik_hostname }}.{{ traefik_domain }}"
set_fact:
entrypoint_hostname: "{{ traefik_hostname }}.{{ traefik_domain }}"
tags:
- always
when: traefik_hostname is defined and traefik_hostname != ""
- name: "Set fact entrypoint_hostname = {{ node_hostname_short }}.{{ traefik_domain }}"
set_fact:
entrypoint_hostname: "{{ node_hostname_short }}.{{ traefik_domain }}"
tags:
- always
when: traefik_hostname is not defined or traefik_hostname == ""
roles:
- name: debug_info
tags:
- debug_info
- role: roles/swap
tags:
- swap
- role: roles/zram
tags:
- zram
- role: roles/tools
tags:
- system
- role: roles/user-developer
tags:
- always
- role: roles/zsh
tags:
- user-developer
- role: docker
docker_install_compose_plugin: true
docker_users:
- "{{ developer_username }}"
tags:
- docker
# - role: docker-rootless
# docker_user: "{{ developer_username }}"
# docker_rootful: "yes"
# docker_rootful_enabled: "yes"
# tags:
# - docker-rootless
- role: roles/homebrew
tags:
- homebrew
- role: code-server
code_server_data_dir: "{{ developer_user_info.home }}/.local/share/code-server"
code_server_user: "{{ developer_username }}"
code_server_host: "{{ vscode_bind_address }}"
code_server_port: "{{ vscode_bind_port }}"
code_server_password: "{{ vscode_password | default('', True) }}"
code_server_password_hash: "{{ vscode_password_hash | default('', True) }}"
code_server_proxy_domain: "{{ entrypoint_hostname }}"
code_server_app_name: "{{ node_hostname_short }}"
code_server_env:
VSCODE_FORCE_USER_ENV: "1"
SHELL: /usr/bin/zsh
tags:
- code-server
- role: roles/traefik
tags:
- traefik
post_tasks:
- name: Populate service facts
service_facts:
tags:
- always
- name: "Disabling services"
service:
name: "{{ item }}"
state: stopped
enabled: no
become: true
when: "service_disabled|length > 0 and item in services"
with_items: "{{ service_disabled | unique }}"
tags:
- always
- name: "Starting services"
service:
name: "{{ item }}"
state: restarted
become: true
when: "service_started|length > 0 and item in services"
with_items: "{{ service_started | unique }}"
tags:
- always
- name: "Restarting services"
service:
name: "{{ item }}"
state: restarted
become: true
when: "service_restarted|length > 0 and item in services"
with_items: "{{ service_restarted | unique }}"
tags:
- always
- name: "Changing default shell to zsh "
shell: 'chsh -s $(which zsh)'
become: true
become_user: root
- name: "Changing default shell to zsh for {{ developer_username }}"
shell: 'chsh -s $(which zsh) {{ developer_username }}'
become: true
become_user: "root"
when: developer_username is defined