-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlabcomex.yml
105 lines (90 loc) · 3.01 KB
/
labcomex.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
# Linux
- hosts: comex_lin,!sje-lin-comex-879470.maquinas.sj.ifsc.edu.br
#any_errors_fatal: true
roles:
- remove_ldap
- role: grub
tipo: grub_soh_lin
tasks:
- name: Adiciona linha do usuario aluno no passwd
ansible.builtin.blockinfile:
path: /etc/passwd
backup: yes
block: |
aluno:x:1001:1001::/home/aluno:
when: ansible_os_family == 'Debian'
- name: Adiciona linha do usuario aluno no group
ansible.builtin.blockinfile:
path: /etc/group
backup: yes
block: |
aluno:x:1001:
when: ansible_os_family == 'Debian'
- name: Cria usuário aluno com a senha aluno
ansible.builtin.user:
name: aluno
shell: /bin/bash
password: $6$B5dpvoG43l67q0sx$r0LDKV2TgNItf/kYx/76l89ZN4LhP/ksYIxp.SSVGttHoSZXLSoB6Hkg2A6y7M7aFJ8zEuauf5kS/yA/P61kN1
groups: aluno
append: yes
when: ansible_os_family == 'Debian'
- name: Cria diretório /home/backup
ansible.builtin.file:
path: /home/backup
state: directory
owner: root
group: root
mode: '0755'
when: ansible_os_family == 'Debian'
- name: Copia aluno.tgz para a máquina
ansible.builtin.get_url:
url: http://ansiblefiles.sj.ifsc.edu.br/aluno_adm.tgz
dest: /home/backup/aluno.tgz
when: ansible_os_family == 'Debian'
##### Configuração do script para apagar o home do aluno a cade inicialização
- name: Adiciona script para zerar o home do aluno
ansible.builtin.copy:
content: |
#!/bin/bash
##Este arquivo eh gerado automaticamente pelo Ansible, nao adianta editar.
#Restaurar o usuario aluno quando manda desligar a maquina ou reiniciar.
rm -rf /var/spool/cron/crontabs/aluno
rm -rf /home/aluno
tar -zxvf /home/backup/aluno.tgz -C / --exclude=home/aluno/.ssh/known_hosts
dest: /etc/init.d/apagaAluno.sh
owner: root
group: root
mode: '0755'
when: ansible_os_family == 'Debian'
tags: apagaAluno
- name: Adiciona o arquivo /lib/systemd/system/apagaAluno.service
ansible.builtin.copy:
content: |
[Unit]
Description=Usuário padrão
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/etc/init.d/apagaAluno.sh
[Install]
WantedBy=reboot.target halt.target poweroff.target
dest: /lib/systemd/system/apagaAluno.service
owner: root
group: root
mode: '0644'
when: ansible_os_family == 'Debian'
tags: apagaAluno
- name: Aplica o daemon-reload e o enable no servico apagaAluno - Linux
ansible.builtin.systemd:
enabled: true
daemon_reload: true
name: apagaAluno
when: ansible_os_family == 'Debian'
tags: apagaAluno
###################### Fim do ApagaAluno
# Windows
- hosts: comex_win
#any_errors_fatal: true
roles:
- ingressa_ldap