-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adiciona ansible_valida_role * commit2 * fix: ajuste da variável * ansible_valida * add:ansible_valida_role.md * fix: ajuste de pr * pequena mudança Co-authored-by: Rafael Gomes <linux.rafa@gmail.com>
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
name: "Valida Roles Ansible" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python_version: | ||
description: "Versão do python" | ||
required: false | ||
type: string | ||
default: '3.9' | ||
os_version: | ||
description: "Versão do sistema operacional" | ||
required: false | ||
default: "ubuntu-20.04" | ||
type: string | ||
secrets: | ||
token: | ||
required: true | ||
jobs: | ||
linter: | ||
runs-on: ${{ inputs.os_version }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ inputs.python_version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements.txt | ||
- name: Run Linters | ||
run: | | ||
ansible-lint | ||
molecule: | ||
runs-on: ${{ inputs.os_version }} | ||
strategy: | ||
matrix: | ||
molecule_distro: [ubuntu1804, ubuntu2004] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ inputs.python_version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements.txt | ||
- name: Force GitHub Actions' docker daemon to use vfs. | ||
run: | | ||
sudo systemctl stop docker | ||
echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' | sudo tee /etc/docker/daemon.json | ||
sudo systemctl start docker | ||
- name: Test with molecule | ||
run: | | ||
molecule test --all | ||
env: | ||
PY_COLORS: '1' | ||
ANSIBLE_FORCE_COLOR: '1' | ||
# Mudar a cor de mensagens de debug para aparecer melhor no fundo | ||
# escuro dos logs do GitHub Action. | ||
ANSIBLE_COLOR_DEBUG: "bright gray" | ||
MOLECULE_DISTRO: ${{ matrix.molecule_distro }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Ansible Valida Role | ||
Github Actions para ser reutilizado nos projetos de Ansible. Faz a validação da sintaxe da role Ansible. | ||
|
||
## Inputs | ||
| Nome | Descrição | Requirida |Default | | ||
|------|-----------|-----------|--------| | ||
|`python_version` | Versão do python | não | 3.9 | | ||
|`os_version` | Versão do sistema operacional | não | ubuntu-20.04 | | ||
|
||
|
||
## Utilizando | ||
Criar a seguintes estrutura de diretórios: | ||
|
||
`.github/workflows/<proposito>.yml` | ||
|
||
Utilize o exemplo abaixo para seu pipeline de CI: | ||
|
||
```yaml | ||
name: "Valida role ansible" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
valida: | ||
uses: "mentoriaiac/cicd_centralizado/.github/workflows/ansible_valida_role.yaml@v1" | ||
secrets: | ||
token: ${{ secrets.TOKEN }} | ||
``` |