-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatlasstack_provision.yml
More file actions
126 lines (112 loc) · 3.08 KB
/
atlasstack_provision.yml
File metadata and controls
126 lines (112 loc) · 3.08 KB
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
---
# AtlasStack - Playbook de Provisionamento Ansible
# Exemplo de automação de configuração de servidores
- name: Provisionamento AtlasStack
hosts: all
become: yes
vars:
app_user: atlasstack
app_dir: /opt/atlasstack
log_dir: /var/log/atlasstack
tasks:
- name: Atualizar cache do apt
apt:
update_cache: yes
cache_valid_time: 3600
when: ansible_os_family == "Debian"
- name: Instalar dependências essenciais
apt:
name:
- curl
- git
- vim
- htop
- python3-pip
- docker.io
state: present
when: ansible_os_family == "Debian"
- name: Criar usuário da aplicação
user:
name: "{{ app_user }}"
shell: /bin/bash
create_home: yes
state: present
- name: Criar diretórios da aplicação
file:
path: "{{ item }}"
state: directory
owner: "{{ app_user }}"
group: "{{ app_user }}"
mode: '0755'
loop:
- "{{ app_dir }}"
- "{{ log_dir }}"
- "{{ app_dir }}/config"
- "{{ app_dir }}/scripts"
- name: Configurar Docker
service:
name: docker
state: started
enabled: yes
- name: Adicionar usuário ao grupo docker
user:
name: "{{ app_user }}"
groups: docker
append: yes
- name: Copiar scripts de diagnose
copy:
src: scripts/diagnose_logs.sh
dest: "{{ app_dir }}/scripts/diagnose_logs.sh"
owner: "{{ app_user }}"
group: "{{ app_user }}"
mode: '0755'
- name: Configurar log rotation
template:
src: templates/logrotate.j2
dest: /etc/logrotate.d/atlasstack
owner: root
group: root
mode: '0644'
when: false # Template precisa ser criado
- name: Configurar firewall UFW
ufw:
state: enabled
rule: allow
port: "{{ item }}"
proto: tcp
loop:
- '22'
- '80'
- '443'
when: ansible_os_family == "Debian"
- name: Verificar status dos serviços
service:
name: "{{ item }}"
state: started
loop:
- docker
register: service_status
- name: Exibir informações do sistema
debug:
msg: |
Sistema: {{ ansible_distribution }} {{ ansible_distribution_version }}
Hostname: {{ ansible_hostname }}
IP: {{ ansible_default_ipv4.address }}
CPU: {{ ansible_processor_vcpus }} cores
Memória: {{ ansible_memtotal_mb }} MB
- name: Criar arquivo de versão
copy:
content: |
AtlasStack Provision
Data: {{ ansible_date_time.iso8601 }}
Servidor: {{ ansible_hostname }}
Versão: 1.0.0
dest: "{{ app_dir }}/VERSION"
owner: "{{ app_user }}"
group: "{{ app_user }}"
mode: '0644'
handlers:
- name: Restart docker
service:
name: docker
state: restarted