Create Ansible project template

This commit is contained in:
Corbin Bartsch 2022-09-19 14:32:59 -04:00
commit 6fbf76cf82
Signed by: coredotbin
GPG Key ID: 32D3B80A08D93212
7 changed files with 41 additions and 0 deletions

4
ansible.cfg Normal file
View File

@ -0,0 +1,4 @@
[defaults]
retry_files_enabled = False
inventory = ./inventory.yaml
vault_password_file = ./.vault-password

16
files/pre-commit Normal file
View File

@ -0,0 +1,16 @@
# Pre-commit hook to ensure vault.yaml is encrypted
#
# Credit goes to Nick Busey from HomelabOS for this neat little trick
# https://gitlab.com/NickBusey/HomelabOS/-/issues/355
if ( git show :vars/vault.yaml | grep -q "$ANSIBLE_VAULT;" ); then
echo "\e[38;5;108mVault Encrypted. Safe to commit.\e[0m"
else
echo "\e[38;5;208mVault not encrypted! Run 'make encrypt' and try again.\e[0m"
exit 1
fi
command -v yamllint > /dev/null && echo "Running yamllint..." && yamllint . || exit 1
command -v ansible-lint > /dev/null && echo "Running ansible-lint..." ansible-lint
# vi: ft=sh

1
group_vars/all.yaml Normal file
View File

@ -0,0 +1 @@
---\n

1
host_vars/host.yaml Normal file
View File

@ -0,0 +1 @@
---\n

1
inventory.yaml Normal file
View File

@ -0,0 +1 @@
---\n

View File

@ -0,0 +1,17 @@
---
- name: Localhost setup
hosts: 127.0.0.1
tasks:
- name: Install packages
ansible.builtin.package:
name: "{{ item }}"
state: present
with_items:
- yamllint
- ansible-lint
- name: Set up git pre-commit hooks
ansible.builtin.copy:
src: ../files/pre-commit
dest: ../.git/hooks/pre-commit
mode: 0755

1
roles/requirements.yaml Normal file
View File

@ -0,0 +1 @@
---\n