Skip to content

Commit

Permalink
Merge pull request #18 from artis3n/molecule
Browse files Browse the repository at this point in the history
Adding Molecule
  • Loading branch information
Ari Kalfus authored Aug 8, 2020
2 parents 6a8f844 + 25702ef commit 7a374f8
Show file tree
Hide file tree
Showing 41 changed files with 1,015 additions and 860 deletions.
2 changes: 0 additions & 2 deletions .ansible-lint

This file was deleted.

3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = E402
max-line-length = 100
40 changes: 0 additions & 40 deletions .github/workflows/ansible.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Ansible

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev
pipenv run ansible-galaxy install -r requirements.yml
pipenv run ansible-galaxy collection install -r requirements.yml
echo "${{ secrets.VAULT_PASS }}" > .vault_pass
- name: Molecule
run: pipenv run molecule test
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
venv/
.vscode
.vault_pass
.idea
roles/
.vagrant/
files/secrets.yml
collections/
__pycache__
36 changes: 36 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# Based on ansible-lint config
extends: default

ignore: |
.pre-commit-config.yaml

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
25 changes: 12 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/usr/bin/make

.PHONY: all
all: install
all: dev-install

.PHONY: install
install:
if [ ! -f /usr/bin/python3 ]; then sudo apt update && sudo apt install -y python3; fi;
if [ ! -f /usr/bin/pip3 ]; then sudo apt update && sudo apt install -y python3-pip; fi;
if [ ! -f ~/.local/bin/pipenv ]; then pip3 install pipenv; fi;
if [ ! -f ~/.local/bin/pipenv ]; then pip3 install --user pipenv; fi;
if [ ! -d ~/.local/share/virtualenvs ]; then mkdir -p ~/.local/share/virtualenvs/; fi;
if [ ! $$(find ~/.local/share/virtualenvs/ -name "dev-setup*") ]; then ~/.local/bin/pipenv install --python /usr/bin/python3; fi;
if [ ! -d ~/.ansible/roles/gantsign.visual-studio-code ]; then ~/.local/bin/pipenv run ansible-galaxy install gantsign.visual-studio-code; fi;
if [ ! -d ~/.ansible/roles/artis3n.bitwarden_app ]; then ~/.local/bin/pipenv run ansible-galaxy install artis3n.bitwarden_app; fi;
if [ ! -d ./collections/ansible_collections/artis3n/github_version ]; then ~/.local/bin/pipenv run ansible-galaxy collection install artis3n.github_version -p ./collections; fi;
if [ ! $$(find ~/.local/share/virtualenvs/ -name "dev-setup*") ]; then ~/.local/bin/pipenv install; fi;
~/.local/bin/pipenv run ansible-galaxy install -r requirements.yml
~/.local/bin/pipenv run ansible-galaxy collection install -r requirements.yml

.PHONY: dev-install
dev-install: install
Expand All @@ -22,19 +21,19 @@ dev-install: install
clean:
-~/.local/bin/pipenv --rm
rm -rf ~/.ansible/roles/
rm -rf ~/.ansible/collections/ansible_collections/artis3n/github_version
rm -rf ~/.ansible/collections/ansible_collections/artis3n/github

.PHONY: lint
lint:
~/.local/bin/pipenv run ansible-lint -c .ansible-lint *.yml
~/.local/bin/pipenv run ansible-lint

.PHONY: provision
provision:
~/.local/bin/pipenv run ansible-playbook --vault-id .vault_pass -i inventory main.yml --ask-become-pass
ANSIBLE_COLOR_DEBUG="magenta" ~/.local/bin/pipenv run ansible-playbook --vault-id .vault_pass -i inventory main.yml --ask-become-pass --force-handlers

.PHONY: secret
secret:
if [ -f ./files/secrets.yml ]; then ~/.local/bin/pipenv run ansible-vault edit ./files/secrets.yml; else ~/.local/bin/pipenv run ansible-vault create ./files/secrets.yml; fi;
.PHONY: test
test:
ANSIBLE_COLOR_DEBUG="magenta" pipenv run molecule test

.PHONY: reset-run
reset-run: clean install run
reset-run: clean install provision
4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ansible = "*"
[dev-packages]
pre-commit = "*"
ansible-lint = "*"
molecule = {extras = ["docker"],version = "*"}
docker = "*"

[requires]
python_version = "3.6"
python_version = "3.8"
Loading

0 comments on commit 7a374f8

Please sign in to comment.