diff --git a/ansible/.gitignore b/ansible/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..eb200e400865633fc2118f09572fb4b85f062139 --- /dev/null +++ b/ansible/.gitignore @@ -0,0 +1,5 @@ +.idea +.venv + +# autogenerated +.template diff --git a/ansible/README.md b/ansible/README.md index 30404ce4c54634bf430d2d154c10c45b8b1eebc1..f2b7189e8bfe48b25418af702dbfe97ced740dc8 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1 +1,14 @@ -TODO \ No newline at end of file +# Ansible + +`ansible.cfg`: Base config for ansible. + +`requirements.galaxy.yaml`: This files content will +be installed with ansible-galaxy. + +`inventory.yaml`: Ansible inventory, by default this +file is already set in the base config so you don't +have to specify it when running + +`bootstrap.sh`: This file can be run everytime to +setup your environment. Look into the file, quite simple. + diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cdeb744a9bc6616aa1dd0d88d383fb645f4e6810 --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host} +inventory = inventory.yaml + +[ssh_connection] +ssh_args = -o StrictHostKeyChecking=accept-new diff --git a/ansible/bootstrap.sh b/ansible/bootstrap.sh new file mode 100755 index 0000000000000000000000000000000000000000..68ea88ed6c14456c1200b98b937251beffcb809d --- /dev/null +++ b/ansible/bootstrap.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# This script creates a Python env, enters it and installs +# ansible and requirements from the requirements.galaxy.yaml + +[[ ! -d .venv ]] && python3 -m venv .venv +source .venv/bin/activate + +pip3 install ansible ansible-lint + +ansible-galaxy install --force -r requirements.galaxy.yaml + +# to stay in our comfy virtualenv +exec "${SHELL:bash}" diff --git a/ansible/inventory.yaml b/ansible/inventory.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f47cfbc1200e34ca8386df49f49c66c79724d48c --- /dev/null +++ b/ansible/inventory.yaml @@ -0,0 +1,11 @@ +all: + hosts: + # Use OpenSSH config to make it comfortable + host1.sch.bme.hu: + host2.sch.bme.hu: + + children: + web: + hosts: + host1.sch.bme.hu: {} + host2.sch.bme.hu: {} diff --git a/ansible/playbook-name/README.md b/ansible/playbook-name/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3ccf8cd8ad3791d2dc1ee2ade99517728b099af1 --- /dev/null +++ b/ansible/playbook-name/README.md @@ -0,0 +1,3 @@ +You place here your usual playbook. + +Example: https://git.sch.bme.hu/kszk/sysadmin/kubernetes/cluster-setup/-/tree/master/ansible/mgmt diff --git a/ansible/requirements.galaxy.yaml b/ansible/requirements.galaxy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b1f25b1c349f4897f40a1a1827cc38c1367401b9 --- /dev/null +++ b/ansible/requirements.galaxy.yaml @@ -0,0 +1,20 @@ +--- +collections: + - community.general + - community.crypto + - ansible.posix + +# You can include roles from Git +roles: + - src: git@git.sch.bme.hu:kszk/sysadmin/kubernetes/base-ansible-role.git + scm: git + version: master + name: kszk-k8s.base + - src: git@git.sch.bme.hu:kszk/sysadmin/kubernetes/router-ansible-role.git + scm: git + version: "1.1.1" + name: kszk-k8s.router + - src: git@git.sch.bme.hu:kszk/sysadmin/kubernetes/iptables-role.git + scm: git + version: master + name: kszk-k8s.iptables