diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4377fee..9a9843f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,11 @@ on: env: VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" SSH_PUB: "${{ secrets.SSH_PUB }}" + ANSIBLE_FORCE_COLOR: '1' jobs: tests: - name: Tests + name: Test Ansible Playbooks runs-on: ubuntu-latest steps: - name: Create SSH pub @@ -33,26 +34,19 @@ jobs: - uses: actions/setup-python@v4 with: python-version: 3.8.9 - - name: Install test dependencies. - run: | - pip install -r requirements.txt + run: pip install -r requirements.txt - name: Syntax Check run: | ansible-playbook setup-linode.yml --syntax-check ansible-playbook setup-homelab.yml --syntax-check + ansible-playbook verify-homelab.yml --syntax-check - name: Setup Linode Instance - run: | - ansible-playbook setup-linode.yml - env: - ANSIBLE_FORCE_COLOR: '1' + run: ansible-playbook setup-linode.yml - name: Setup Home Lab - run: | - ansible-playbook setup-homelab.yml - env: - ANSIBLE_FORCE_COLOR: '1' + run: ansible-playbook setup-homelab.yml - name: Verify Home Lab - run: | - ansible-playbook verify-homelab.yml - env: - ANSIBLE_FORCE_COLOR: '1' + run: ansible-playbook verify-homelab.yml + - name: Delete Linode Instance + run: ansible-playbook setup-linode.yml --extra-vars "state=absent" + diff --git a/.github/workflows/delete-linode-instances.yml b/.github/workflows/delete-linode-instances.yml new file mode 100644 index 0000000..697d653 --- /dev/null +++ b/.github/workflows/delete-linode-instances.yml @@ -0,0 +1,41 @@ +--- +name: Delete test linode instance +on: + schedule: + - cron: "0 0 * * *" # delete at midnight every day + +env: + VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" + SSH_PUB: "${{ secrets.SSH_PUB }}" + ANSIBLE_FORCE_COLOR: '1' + +jobs: + delete-linode-instance: + name: Delete Linode Instance + runs-on: ubuntu-latest + steps: + - name: Create SSH pub + run: | + echo "creating ~/.ssh/id_rsa.pub file" + mkdir -p ~/.ssh/ + echo "$SSH_PUB" > ~/.ssh/id_rsa.pub + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_KEY }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + - name: Check out the codebase. + uses: actions/checkout@v3 + - name: Prepare Test Files + run: | + mv tests/.vault-pass.sh ./.vault-pass.sh + mv tests/ansible.cfg ./ansible.cfg + mv tests/hosts.ini ./hosts.ini + - uses: actions/setup-python@v4 + with: + python-version: 3.8.9 + - name: Install test dependencies. + run: pip install -r requirements.txt + - name: Delete Linode Instance + run: ansible-playbook setup-linode.yml --extra-vars "state=absent" + diff --git a/group_vars/linode.yml b/group_vars/linode.yml index c41ab43..be21341 100644 --- a/group_vars/linode.yml +++ b/group_vars/linode.yml @@ -3,7 +3,6 @@ vault_file: vault_vars/linode-vault.yml # any linode specific variables go here configure_mergefs: false -configure_samba: false services: - name: gitea - name: mealie diff --git a/group_vars/qnap.yml b/group_vars/qnap.yml index 77cca77..03ee1bb 100644 --- a/group_vars/qnap.yml +++ b/group_vars/qnap.yml @@ -23,19 +23,6 @@ devices: - uuid: "c528bf82-61ab-4f3d-87e0-d1e6e02ef7ec" # /dev/sdf path: "/mnt/ssd0/" - -configure_samba: true -samba_group: smbgroup -samba_user: smbuser -users: - - name: cianhatton -shares: - - /share - - /share/public_files - - /share/private_files - - /share/cian_files - - services: - name: gitea - name: mealie @@ -52,9 +39,6 @@ services: - name: photoprism - name: olivetin -extra_hosts: - - "qnap:192.168.178.42" - # any additional docker networks that should be created docker_networks: - mariadb_net diff --git a/group_vars/servers.yml b/group_vars/servers.yml index 940eb91..9c25acb 100644 --- a/group_vars/servers.yml +++ b/group_vars/servers.yml @@ -28,3 +28,15 @@ docker_networks: [] homelab_group: cianhatton homelab_user: cianhatton + +configure_samba: true +samba_group: smbgroup +samba_user: smbuser +users: + - name: cianhatton +shares: + - /share + - /share/public_files + - /share/private_files + - /share/cian_files + diff --git a/hosts.ini b/hosts.ini index 5e7cb1f..c864d9d 100644 --- a/hosts.ini +++ b/hosts.ini @@ -9,5 +9,5 @@ cianhatton@qnap # BEGIN ANSIBLE MANAGED BLOCK [linode] -root@198.74.59.177 +root@172.104.8.72 # END ANSIBLE MANAGED BLOCK diff --git a/roles/setup_linode/tasks/main.yml b/roles/setup_linode/tasks/main.yml index e2f0a32..9538e1a 100644 --- a/roles/setup_linode/tasks/main.yml +++ b/roles/setup_linode/tasks/main.yml @@ -12,7 +12,7 @@ root_pass: "{{ password }}" authorized_keys: "{{ ssh_keys }}" group: servers - state: present + state: "{{ state }}" register: my_linode - name: Wait for SSH to come up diff --git a/setup-linode.yml b/setup-linode.yml index 13bf16a..9d39165 100644 --- a/setup-linode.yml +++ b/setup-linode.yml @@ -3,3 +3,5 @@ become: true roles: - role: 'roles/setup_linode' + vars: + state: present