feat: base configuration automation
This commit is contained in:
commit
e4770a7343
70 changed files with 2489 additions and 0 deletions
106
Taskfile.yml
Normal file
106
Taskfile.yml
Normal file
|
@ -0,0 +1,106 @@
|
|||
version: '3'
|
||||
|
||||
env:
|
||||
DOCKER_REPOSITORY: pouncetech/molecule
|
||||
|
||||
vars:
|
||||
PYTHON_WRAPPER: '{{.ROOT_DIR}}/scripts/python_wrapper.sh'
|
||||
MOLECULE_DIR: '{{.ROOT_DIR}}/collections/ansible_collections/nullified/infrastructure/extensions'
|
||||
|
||||
tasks:
|
||||
venv:setup:
|
||||
desc: install a Python3 virtualenv and all the required ansible / molecule dependencies.
|
||||
cmds:
|
||||
- |
|
||||
set -e
|
||||
rm -rf ./venv || true
|
||||
python3 -m virtualenv --download venv
|
||||
./venv/bin/python3 -m pip install --upgrade -r requirements.txt
|
||||
status:
|
||||
- test -d venv
|
||||
|
||||
test:modules:
|
||||
desc: run `ansible-test sanity` on collections to find common issues for modules and collections
|
||||
dir: collections/ansible_collections
|
||||
vars:
|
||||
ANSIBLE_COLLECTIONS:
|
||||
sh: find -mindepth 2 -maxdepth 2 -type d
|
||||
cmds:
|
||||
- for: { var: ANSIBLE_COLLECTIONS }
|
||||
task: 'test:module:sanity'
|
||||
vars:
|
||||
COLLECTION_PATH: 'collections/ansible_collections/{{.ITEM}}'
|
||||
|
||||
test:module:sanity:
|
||||
internal: true
|
||||
dir: '{{.COLLECTION_PATH}}'
|
||||
preconditions:
|
||||
- test -d tests
|
||||
cmds:
|
||||
- '{{.PYTHON_WRAPPER}} ansible-test sanity --docker default'
|
||||
|
||||
test:collections:
|
||||
desc: run molecule tests for all roles and collections.
|
||||
dir: collections/ansible_collections
|
||||
vars:
|
||||
ANSIBLE_COLLECTIONS:
|
||||
sh: find -mindepth 2 -maxdepth 2 -type d
|
||||
cmds:
|
||||
- for: { var: ANSIBLE_COLLECTIONS }
|
||||
task: 'test:collection:molecule'
|
||||
vars:
|
||||
COLLECTION_PATH: 'collections/ansible_collections/{{.ITEM}}'
|
||||
|
||||
test:collection:molecule:
|
||||
internal: true
|
||||
dir: '{{.COLLECTION_PATH}}/extensions'
|
||||
preconditions:
|
||||
- test -d molecule
|
||||
cmds:
|
||||
- '{{.PYTHON_WRAPPER}} molecule test'
|
||||
|
||||
module:github_artifact:
|
||||
desc: run a module from the collection for testing purposes
|
||||
vars:
|
||||
PLUGINS_DIR: '{{.ROOT_DIR}}/collections/ansible_collections/nullified/infrastructure/plugins'
|
||||
cmd: |
|
||||
{{.PYTHON_WRAPPER}} python3 {{.PLUGINS_DIR}}/modules/github_artifact.py {{.PLUGINS_DIR}}/tests/github_artifact.json |
|
||||
{{.PYTHON_WRAPPER}} python3 -m json.tool | {{.PYTHON_WRAPPER}} pygmentize -l json
|
||||
|
||||
docker:build:
|
||||
desc: build docker images locally.
|
||||
vars:
|
||||
DOCKERFILE_IMAGES:
|
||||
sh: find images -type f -name 'Dockerfile-*'
|
||||
cmds:
|
||||
- for: { var: DOCKERFILE_IMAGES }
|
||||
task: 'docker:build:image'
|
||||
vars:
|
||||
DOCKERFILE: '{{.ITEM}}'
|
||||
DOCKER_CONTEXT: images
|
||||
IMAGE_TAG: '{{.ITEM | splitList "/" | last | replace "Dockerfile-" ""}}'
|
||||
|
||||
docker:build:image:
|
||||
internal: true
|
||||
sources:
|
||||
- '{{.DOCKERFILE}}'
|
||||
cmds:
|
||||
- docker buildx build --load -t "{{.DOCKER_REPOSITORY}}:{{.IMAGE_TAG}}" -f {{.DOCKERFILE}} {{.DOCKER_CONTEXT}}
|
||||
status:
|
||||
- docker image ls --format '{{"{{"}} .Tag {{"}}"}}' | grep -E '^{{.IMAGE_TAG}}$'
|
||||
|
||||
docker:push:
|
||||
desc: push locally built images
|
||||
cmds:
|
||||
- 'echo docker push $DOCKER_REPOSITORY:$IMAGE_TAG'
|
||||
env:
|
||||
IMAGE_TAG:
|
||||
|
||||
venv:
|
||||
desc: execute a python3 command using the virtualenv wrapper
|
||||
cmd: '{{.PYTHON_WRAPPER}} {{.CLI_ARGS}}'
|
||||
|
||||
molecule:
|
||||
desc: execute a molecule command
|
||||
dir: '{{.MOLECULE_DIR}}'
|
||||
cmd: '{{.PYTHON_WRAPPER}} molecule {{.CLI_ARGS}}'
|
Loading…
Add table
Add a link
Reference in a new issue