-
Notifications
You must be signed in to change notification settings - Fork 5
/
ad_hoc_laboratorios.yml
415 lines (358 loc) · 12.1 KB
/
ad_hoc_laboratorios.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
---
# - name: Servidor controlador
# hosts: controlador
# tasks:
# # USAR O CPF COMO USUÁRIO E A SENHA DEVE TER NO MÍNIMO 8 dígitos
# - name: Cria usuários para o IFSC-Terceirizados
# ansible.builtin.shell: "samba-tool user create {{ item.user }} {{ item.password }} --userou=OU=terceirizados && samba-tool user setexpiry --days=365 {{ item.user }}"
# loop:
# - { user: 12345678910, password: 87654321 }
# ##### Criar e configurar a conta aluno em maquinas windows ############ ( não está funcionando )
# - hosts: sje-ctic-866467.maquinas.sj.ifsc.edu.br
# roles:
# - create_user_aluno
# - name: Manage local user aluno on a Windows remote host # ( ESTÁ funcionando )
# hosts: sje-ctic-866467.maquinas.sj.ifsc.edu.br
# gather_facts: no
# vars:
# ansible_winrm_transport: basic
# ansible_winrm_server_cert_validation: ignore
# tasks:
# - name: Ensure user "aluno" exists and set password
# win_user:
# name: aluno
# password: aluno
# password_never_expires: yes
# user_cannot_change_password: yes
# state: present
# - name: Add user "aluno" to local group "Usuários"
# win_group_membership:
# name: Usuários
# members:
# - aluno
# state: present
#
# ## Remover do LDAP ##############
# - hosts: sj-lin-ciehu-710790.maquinas.sj.ifsc.edu.br
# roles:
# - remove_ldap
# ## #### Update 11_to_12 Debian #########
# - hosts: sj-lin-dire-38132.maquinas.sj.ifsc.edu.br
# roles:
# - upgrade_11to12
# ###### Criar e configurar a conta aluno em maquinas Linux ##############
# - name: Criar conta de usuário 'aluno' e configurar ambiente
# hosts: sj-lin-ciehu-710790.maquinas.sj.ifsc.edu.br
# become: yes
# tasks:
# - name: Criar grupo vboxusers se não existir
# group:
# name: vboxusers
# state: present
# - name: Criar usuário 'aluno'
# user:
# name: aluno
# password: "{{ 'aluno' | password_hash('sha512', 'mysalt') }}" # Substitua 'mysalt' por um valor seguro
# groups: vboxusers
# shell: /bin/bash
# create_home: yes
# register: aluno_user
# - name: Verificar se o usuário 'aluno' foi criado
# command: id aluno
# register: aluno_id
# ignore_errors: true
# - name: Garantir que o diretório home /home/aluno existe
# file:
# path: /home/aluno
# state: directory
# owner: aluno
# group: aluno
# mode: '0755'
# when: aluno_user.changed
# - name: Verificar se o diretório home /home/aluno foi criado
# stat:
# path: /home/aluno
# register: aluno_home
# - name: Mensagem de sucesso se o usuário 'aluno' foi criado com sucesso
# debug:
# msg: "*** Conta Aluno criada com sucesso ****"
# when: aluno_id.rc == 0 and aluno_home.stat.exists
# - name: Mostrar detalhes se o usuário 'aluno' não foi criado com sucesso
# debug:
# msg: "Erro: Falha ao criar conta de aluno"
# when: aluno_id.rc != 0 or not aluno_home.stat.exists
######### Executar o Windows Update em Hosts windows remotos
# - name: Executar o Windows Update em Hosts windows remotos
# hosts: sj-labter-614120.maquinas.sj.ifsc.edu.br
# tasks:
# - name: Run Windows Update
# win_updates:
# category_names:
# - CriticalUpdates
# - SecurityUpdates
# - UpdateRollups
# - FeaturePacks
# - ServicePacks
# state: installed
# reboot: yes
# - hosts: csfio_lin
# tasks:
# - name: Mantem o estado do arquivo /etc/network/interfaces - Linux
# ansible.builtin.copy:
# content: |
# search sj.ifsc.edu.br
# nameserver 191.36.8.66
# nameserver 191.36.8.90
# nameserver 191.36.15.200
# dest: /etc/resolv.conf
# owner: root
# group: root
# mode: 0644
# - hosts: laboratorios_lin
# tasks:
# - name: Copia um arquivo para as maquinas - Linux
# ansible.builtin.copy:
# src: /dados/backup/{{ item }}
# dest: /usr/share/applications/
# owner: root
# group: root
# mode: 0644
# with_items:
# - google-chrome.desktop
# - firefox-esr.desktop
# - name: Executa alguma coisa
# hosts: sj-ctic-1bw10.maquinas.sj.ifsc.edu.br
# tasks:
# - name: Desativa o início rápido para o WOL funcionar
# ansible.windows.win_regedit:
# path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power
# name: HiberbootEnabled
# data: 0
# type: dword
## Executar no final do semestre
# - hosts: programacao_lin
# roles:
# - chaves_ssh
# - firewall_labs
# - final_semestre
# - gradle
# roles:
# - role: atualiza_mac
# play: 1
# play: 0 desativa
# play: 1 ativa
# - hosts: sj-lin-dire-38132.maquinas.sj.ifsc.edu.br
# tasks:
# - name: Configura printers.conf
# ansible.builtin.copy:
# content: |
# ServerName 191.36.8.74
# dest: /etc/cups/client.conf
# owner: 'root'
# group: 'root'
# mode: '0644'
# - hosts: all
# tasks:
# - name: enable TLSv1.2 support
# win_regedit:
# path: HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\{{ item.type }}
# name: '{{ item.property }}'
# data: '{{ item.value }}'
# type: dword
# state: present
# register: enable_tls12
# loop:
# - type: Server
# property: Enabled
# value: 1
# - type: Server
# property: DisabledByDefault
# value: 0
# - type: Client
# property: Enabled
# value: 1
# - type: Client
# property: DisabledByDefault
# value: 0
# when: (ansible_os_family == 'Windows' and ansible_os_name == 'Microsoft Windows 7 Professional')
# - name: reboot if TLS config was applied
# win_reboot:
# when: enable_tls12 is changed
# - hosts: laboratorios_win
# tasks:
# - name: Corrigir problema com senha expirada
# ansible.windows.win_user:
# name: aluno
# password_expired: false
# password_never_expires: true
# user_cannot_change_password: true
# when: ansible_os_family == 'Windows'
# # LIMPA TEMP WINDOWS
# - hosts: laboratorios_win
# roles:
# - role: limpa_temp_windows
# play: 0
# # play: 0 desativa
# # play: 1 ativa
# # ATUALIZA MAC
# # SEMPRE VERIFICAR O HOST QUE QUER ATINGIR
# - hosts: laboratorios_lin
# roles:
# - role: atualiza_mac
# play: 0
# # play: 0 desativa
# # play: 1 ativa
## DESCOMENTAR PARA CORRIGIR O EPOPTES, PEGAR AS CHAVES DO SERVER. COMENTAR NOVAMENTE DEPOIS.
## LEMBRAR DE RODAR COM A OPÇÃO -l GRUPO_DO_LAB
# - hosts: laboratorios_lin
# tasks:
# - name: Pegar as chaves do epoptes server no cliente - Linux
# shell: /usr/sbin/epoptes-client -c
# when: ansible_os_family == 'Debian'
##RESOLVENDO PROBLEMA DAS INTERFACES DE REDE DO OPENVSWITCH NOS LABS
# - hosts: laboratorios_lin
# tasks:
# - name: Apagar as interfaces virtuais de rede
# shell: for x in $(ovs-vsctl list-br); do ovs-vsctl del-br ${x}; done
# when: ansible_os_family == 'Debian'
# - hosts: sidi_win
# tasks:
# - name: Turn off computers Windows
# raw: shutdown /s /hybrid /t 15 /c "We are turning computers off after maintenance"
# - hosts: programacao_lin
# tasks:
# - name: Reboot computer para Windows
# raw: grub-reboot 2
# - name: Turn off computers
# raw: reboot
# - hosts: laboratorios_lin
# roles:
# - role: restaura_vms
# nome_vms:
# - 1-Servidor
# - 2-Servidor
# - 3-Servidor
# - 4-Servidor
# - 5-Servidor
# - 6-Servidor
# - 7-Servidor
# - hosts: laboratorios_lin
# roles:
# - role: restaura_vms_grafico
# nome_vms:
# - 1-Grafico
# - 2-Grafico
# - 3-Grafico
# - 4-Grafico
# #
# ## Utilizado para fazer o hold do linux-image e linux-headers e reinstalar o virtualbox-dkms
# #
# - hosts: laboratorios_lin
# tasks:
# - name: apaga /etc/apt/sources.list.d/ftp_debian_org_debian.list
# file:
# path: /etc/apt/sources.list.d/ftp_debian_org_debian.list
# state: absent
# when: ansible_os_family == 'Debian'
# - name: Run the equivalent of "apt-get update" as a separate step
# apt:
# update_cache: yes
# when: ansible_os_family == 'Debian'
# - name: Upgrade all packages to the latest version
# apt:
# name: "*"
# state: latest
# when: ansible_os_family == 'Debian'
# - name: seleciona a entrada grub 0 para o próximo boot
# shell: grub-reboot 0
# when: ansible_os_family == 'Debian'
# - name: Unconditionally reboot the machine with all defaults
# reboot:
# when: ansible_os_family == 'Debian'
# - name: instala kernel headers atual
# apt:
# name: "linux-headers-{{ ansible_kernel }}"
# when: ansible_os_family == 'Debian'
# # Quando quiser atualizar precisar alterar o selection para "install"
# - name: Faz hold no linux-image
# dpkg_selections:
# name: "linux-image-{{ ansible_kernel }}"
# selection: hold
# when: ansible_os_family == 'Debian'
# # Quando quiser atualizar precisar alterar o selection para "install"
# - name: Faz hold no linux-image
# dpkg_selections:
# name: "linux-headers-{{ ansible_kernel }}"
# selection: hold
# when: ansible_os_family == 'Debian'
# - name: reinstala virtualbox-dkms
# shell: aptitude reinstall virtualbox-dkms
# when: ansible_os_family == 'Debian'
# - hosts: all
# tasks:
# - name: Get the MAC address
# debug: msg="{{ hostvars[inventory_hostname].ansible_default_ipv4.macaddress }}"
# - name: Salvar na maquina que esta executando o ansible os enderecos macs
# local_action: shell echo "{{ hostvars[inventory_hostname].ansible_default_ipv4.macaddress }}" >> /tmp/output
# - win_shell: netsh interface ip add wins name=LAN addr=172.18.109.10 index=0
# - name: Install HPLIP on Debian
# hosts: sj-lin-biblio-36076.maquinas.sj.ifsc.edu.br
# become: yes
# tasks:
# - name: Update apt cache
# apt:
# update_cache: yes
# - name: Install required packages
# apt:
# name: "{{ item }}"
# state: present
# with_items:
# - hplip
# - hplip-gui
# - name: Ensure the cups service is running
# service:
# name: cups
# state: started
# enabled: yes
#
######################### Instala Gnome Online Accounts no debian ##############
#
# - name: Install gnome-online-accounts
# apt:
# name: gnome-online-accounts
# state: present
################### Limpar home do aluno no windows ###################
# - name: Remove conta do aluno
# win_user:
# name: aluno
# state: absent
# when: ansible_os_family == 'Windows'
# - name: Remove profile do aluno
# win_user_profile:
# name: aluno
# state: absent
# remove_multiple: yes
# when: ansible_os_family == 'Windows'
# - name: Remove a pasta do aluno
# win_file:
# path: C:\Users\aluno
# state: absent
# when: ansible_os_family == 'Windows'
# - name: cria usuário aluno
# win_user:
# name: aluno
# password_expired: no
# state: present
# user_cannot_change_password: yes
# groups:
# - "Usuários"
# when: ansible_os_family == 'Windows'
#######################################################################
######################## OBSERVAÇÕES IMPORTANTES ######################
#######################################################################
#######################################################################
# Há roles que precisam ser atualizados de tempos em tempos.
# Deve-se adicionar aqui os roles que perceberem que necessitam atualizações
# - Atualizar os patrimonio do role firewall_labs.
# - Uma vez por ano tem que atualizar o role do irpf, porém não estamos mais autorizados
# a instalar ele.