diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..806ba9f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +--- +name: CI +on: + push: + +env: + VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Check out the codebase. + uses: actions/checkout@v3 + - name: Install test dependencies. + run: | + sudo python3 -m pip install --upgrade pip + sudo pip3 install ansible + - name: Syntax Check + run: | + ansible-playbook setup-linode.yml --syntax-check + ansible-playbook setup-homelab.yml --syntax-check + - 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 + ansible-playbook setup-linode.yml + env: + ANSIBLE_FORCE_COLOR: '1' diff --git a/hosts.ini b/hosts.ini index 165ce6a..5e7cb1f 100644 --- a/hosts.ini +++ b/hosts.ini @@ -7,10 +7,7 @@ linode [qnap] cianhatton@qnap -[localhost] -localhost ansible_connection=local ansible_python_interpreter=/Users/chatton/checkouts/ansible-homelab/venv/bin/python - # BEGIN ANSIBLE MANAGED BLOCK [linode] -root@45.79.165.198 +root@198.74.59.177 # END ANSIBLE MANAGED BLOCK diff --git a/roles/setup_linode/defaults/main.yml b/roles/setup_linode/defaults/main.yml index ea79b65..bba11e6 100644 --- a/roles/setup_linode/defaults/main.yml +++ b/roles/setup_linode/defaults/main.yml @@ -8,3 +8,7 @@ label: simple-linode hosts: - user: root ip: "{{my_linode.instance.ipv4[0]}}" + +# https://www.linode.com/community/questions/17190/obtain-a-list-of-image-and-plan-types-using-linode-apicli +type: g6-standard-2 +region: us-east diff --git a/roles/setup_linode/tasks/main.yml b/roles/setup_linode/tasks/main.yml index 43f90f2..e2f0a32 100644 --- a/roles/setup_linode/tasks/main.yml +++ b/roles/setup_linode/tasks/main.yml @@ -6,8 +6,8 @@ linode_v4: label: "{{ label }}" access_token: "{{ token }}" - type: g6-nanode-1 - region: us-east + type: "{{ type }}" + region: "{{ region }}" image: linode/debian11 root_pass: "{{ password }}" authorized_keys: "{{ ssh_keys }}" @@ -15,7 +15,6 @@ state: present register: my_linode - - name: Wait for SSH to come up local_action: module: wait_for diff --git a/tests/.vault-pass.sh b/tests/.vault-pass.sh new file mode 100755 index 0000000..d913f4e --- /dev/null +++ b/tests/.vault-pass.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "${VAULT_PASSWORD}" diff --git a/tests/ansible.cfg b/tests/ansible.cfg new file mode 100644 index 0000000..992fb32 --- /dev/null +++ b/tests/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +default_module_path=library +inventory=hosts.ini +vault_password_file=.vault-pass.sh +host_key_checking = False +enable_plugins = linode diff --git a/tests/hosts.ini b/tests/hosts.ini new file mode 100644 index 0000000..a516c87 --- /dev/null +++ b/tests/hosts.ini @@ -0,0 +1,6 @@ +[servers:children] +linode + +# BEGIN ANSIBLE MANAGED BLOCK +[linode] +# END ANSIBLE MANAGED BLOCK