Skip to content

Commit

Permalink
definição do padrão
Browse files Browse the repository at this point in the history
Será uma role por repo github
Os arquivos precisam estar na raiz
O verify testinfra é melhor do que ansible
Renomeado o nome da role
  • Loading branch information
gomex committed Jan 10, 2021
1 parent 2e55ca6 commit a66e7eb
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hosts
.venv/
molecule/*/tests/__pycache__
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@ Aqui teremos a lista de tarefas e qualquer documento necessário pra ajudar pess
```
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install "molecule[docker,lint]"
$ pip install "molecule[docker,lint]" pytest-testinfra
```
- Testando as roles:
- Testando a role:
```
$ cd /roles/setting-server
$ molecule test
```
- Testando rapidamente após modificação:
```
$ molecule create
$ molecule converge
$ molecule verify
```
- Não esqueça de destruir quando acabar seus testes:
```
$ molecule destroy
```
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# defaults file for iac-role-basica
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for iac-role-basica
2 changes: 0 additions & 2 deletions hosts.example

This file was deleted.

5 changes: 1 addition & 4 deletions roles/setting-server/meta/main.yml → meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
galaxy_info:
author: Dados Abertos de Feira
description: Role para configurar servidor
description: Role básica para configurar servidor

platforms:
- name: Ubuntu
release: bionic

dependencies:
- dokku_bot.ansible_dokku
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
cache_valid_time: 3600
when: ansible_os_family == 'Debian'
roles:
- role: setting-server
- role: iac-role-basica
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ provisioner:
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
verifier:
name: ansible
name: testinfra
env:
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
12 changes: 12 additions & 0 deletions molecule/default/tests/test_docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_is_docker_installed(host):
package_docker = host.package('docker-ce')

assert package_docker.is_installed
12 changes: 12 additions & 0 deletions molecule/default/tests/test_dokku.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_is_docker_installed(host):
cmd = host.run("dokku apps:list")

assert cmd.rc == 0
1 change: 0 additions & 1 deletion playbook.yml

This file was deleted.

29 changes: 0 additions & 29 deletions roles/setting-server/.travis.yml

This file was deleted.

33 changes: 0 additions & 33 deletions roles/setting-server/.yamllint

This file was deleted.

2 changes: 0 additions & 2 deletions roles/setting-server/defaults/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/setting-server/handlers/main.yml

This file was deleted.

8 changes: 0 additions & 8 deletions roles/setting-server/molecule/default/verify.yml

This file was deleted.

7 changes: 0 additions & 7 deletions roles/setting-server/requirements.yml

This file was deleted.

38 changes: 0 additions & 38 deletions roles/setting-server/tasks/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/setting-server/vars/main.yml

This file was deleted.

13 changes: 13 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Criar a conta do usuário gomex
user:
name: gomex
shell: /bin/bash
password: "$6$RsOxdMJD$TVnLVpoFK6SGb8XEY3aEI71aJ.dGiWh3FaIrBkjkcMLpX89dgjjl4LglYV1iZbXdamCf/u0U/qw.H2VW0qULA0"
groups: sudo
append: yes
- name: Adicionar a chave publica para o usuário gomex
authorized_key:
user: gomex
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYc9rlj0wKka5t31T4EiTanSmXpswDg00dYmuwdvEW3bAovcdzt6p3kgFxpPaZj7X6oFfvSCXpoL+/yjngujEW9CGbqfdVyvCodIuIaGuoUsxo7dtMCLzqZtGGe1m6xoTyNqZQzv68nF1fZ/ku7YNK9HGKKcjNJVvs6ocqK5Jbdb6IGRF64kP4hx8IX5n8CU8APn5esrh6BNhViKHWYIGDYoFkd54Z4CeD156BYl1OhWbla6u1vOntpj1uw3Lp+haAWbXSJMCpztsYPeynrQ14GUbHPRAsO4IILD5CtZWsp16VnEIAhsIqrnzp1BGTduwbX5VVzY3K7JdFNEWThFhd"
File renamed without changes.
2 changes: 1 addition & 1 deletion roles/setting-server/tests/test.yml → tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- hosts: localhost
remote_user: root
roles:
- setting-server
- iac-role-basica
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for iac-role-basica

0 comments on commit a66e7eb

Please sign in to comment.