From daa3ec06368682043b831c1cdc59c78a079086c9 Mon Sep 17 00:00:00 2001
From: Rafael Laszlo <rlacko99@gmail.com>
Date: Mon, 8 Nov 2021 22:53:11 +0100
Subject: [PATCH] Add ansible base files

---
 ansible/.gitignore               |  5 +++++
 ansible/README.md                | 15 ++++++++++++++-
 ansible/ansible.cfg              |  6 ++++++
 ansible/bootstrap.sh             | 14 ++++++++++++++
 ansible/inventory.yaml           | 11 +++++++++++
 ansible/playbook-name/README.md  |  3 +++
 ansible/requirements.galaxy.yaml | 20 ++++++++++++++++++++
 7 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 ansible/.gitignore
 create mode 100644 ansible/ansible.cfg
 create mode 100755 ansible/bootstrap.sh
 create mode 100644 ansible/inventory.yaml
 create mode 100644 ansible/playbook-name/README.md
 create mode 100644 ansible/requirements.galaxy.yaml

diff --git a/ansible/.gitignore b/ansible/.gitignore
new file mode 100644
index 0000000..eb200e4
--- /dev/null
+++ b/ansible/.gitignore
@@ -0,0 +1,5 @@
+.idea
+.venv
+
+# autogenerated
+.template
diff --git a/ansible/README.md b/ansible/README.md
index 30404ce..f2b7189 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 0000000..cdeb744
--- /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 0000000..68ea88e
--- /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 0000000..f47cfbc
--- /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 0000000..3ccf8cd
--- /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 0000000..b1f25b1
--- /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
-- 
GitLab