Skip to content

Commit

Permalink
feat/action valida ansible (#9)
Browse files Browse the repository at this point in the history
* 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
rafaelm93 and gomex authored May 7, 2022
1 parent c1d453b commit 8b1da2c
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/ansible_valida_role.yaml
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 }}
31 changes: 31 additions & 0 deletions docs/ansible_valida_role.md
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 }}
```

0 comments on commit 8b1da2c

Please sign in to comment.