diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..1130f0c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,18 @@ +--- +name: Test Playbook +on: + pull_request: + push: + branches: + - "master" + +jobs: + run-tests: + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v3 + - name: "Build docker image" + run : | + docker build . -t test + docker run test diff --git a/.gitignore b/.gitignore index 485dee6..e04276f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea +venv diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..efe33c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM debian + +# Install prerequisities for Ansible +RUN apt-get update +RUN apt-get -y install python3 python3-nacl python3-pip libffi-dev + +# Install ansible +RUN pip3 install ansible + +# Copy your ansible configuration into the image +ADD ansible /ansible +COPY ansible/homelab/hosts /etc/ansible/hosts + +CMD [ "ansible-playbook", "/ansible/homelab/playbooks/test.yml", "-v"] diff --git a/ansible/homelab/hosts b/ansible/homelab/hosts new file mode 100644 index 0000000..b345d20 --- /dev/null +++ b/ansible/homelab/hosts @@ -0,0 +1,2 @@ +[servers] +localhost \ No newline at end of file diff --git a/ansible/homelab/playbooks/test.yml b/ansible/homelab/playbooks/test.yml new file mode 100644 index 0000000..253fd30 --- /dev/null +++ b/ansible/homelab/playbooks/test.yml @@ -0,0 +1,19 @@ +--- +- hosts: servers + connection: local + tasks: + - name: Update and upgrade apt packages + become: true + apt: + upgrade: yes + update_cache: yes + cache_valid_time: 86400 + + - name: Install aptitude + apt: + name: aptitude + state: latest + update_cache: true + + - name: Install Docker + import_tasks: ../tasks/install-docker-tasks.yml diff --git a/ansible/homelab/tasks/install-docker-tasks.yml b/ansible/homelab/tasks/install-docker-tasks.yml new file mode 100644 index 0000000..9894c97 --- /dev/null +++ b/ansible/homelab/tasks/install-docker-tasks.yml @@ -0,0 +1,33 @@ +--- +- name: Install required system packages + apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - software-properties-common + - python3-pip + - virtualenv + - python3-setuptools + state: latest + update_cache: true + +- name: Add Docker GPG apt Key + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + +- name: Add Docker Repository + apt_repository: + repo: deb https://download.docker.com/linux/ubuntu focal stable + state: present + +- name: Update apt and install docker-ce + apt: + name: docker-ce + state: latest + update_cache: true + +- name: Install Docker Module for Python + pip: + name: docker \ No newline at end of file diff --git a/ansible/redeploy-dashy.yml b/ansible/playbooks/redeploy-dashy.yml similarity index 100% rename from ansible/redeploy-dashy.yml rename to ansible/playbooks/redeploy-dashy.yml diff --git a/ansible/playbooks/vm-test.yml b/ansible/playbooks/vm-test.yml new file mode 100644 index 0000000..95bb4b5 --- /dev/null +++ b/ansible/playbooks/vm-test.yml @@ -0,0 +1,49 @@ +--- +- hosts: servers + connection: local + tasks: + - name: Update and upgrade apt packages + become: true + apt: + upgrade: yes + update_cache: yes + cache_valid_time: 86400 + + - name: Install aptitude + apt: + name: aptitude + state: latest + update_cache: true + + - name: Install required system packages + apt: + pkg: + - apt-transport-https + - ca-certificates + - curl + - software-properties-common + - python3-pip + - virtualenv + - python3-setuptools + state: latest + update_cache: true + + - name: Add Docker GPG apt Key + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + + - name: Add Docker Repository + apt_repository: + repo: deb https://download.docker.com/linux/ubuntu focal stable + state: present + + - name: Update apt and install docker-ce + apt: + name: docker-ce + state: latest + update_cache: true + + - name: Install Docker Module for Python + pip: + name: docker \ No newline at end of file diff --git a/ansible/volume-restore.yml b/ansible/playbooks/volume-restore.yml similarity index 100% rename from ansible/volume-restore.yml rename to ansible/playbooks/volume-restore.yml