diff --git a/.gitea/workflows/deploy_playbook.yaml b/.gitea/workflows/deploy_playbook.yaml new file mode 100644 index 0000000..912e49a --- /dev/null +++ b/.gitea/workflows/deploy_playbook.yaml @@ -0,0 +1,36 @@ +name: Ansible CI/CD + +on: + pull_request: + branches: + - main + types: [closed] + + +jobs: + deploy: + name: Deploy Ansible Playbook + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up SSH + run: | + echo "${{ secrets.DEVHOST_SSH_PRIVATE_KEY }}" > private_key.pem + chmod 600 private_key.pem + + - name: Install Ansible + shell: bash + run: | + sudo apt update + sudo apt install -y ansible + + - name: Run Ansible Playbook + env: + ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }} + ANSIBLE_HOST_KEY_CHECKING: False + run: | + ansible-playbook -i opdracht-2/inventory.ini opdracht-2/nginx.yml --private-key private_key.pem -u ${{ secrets.DEVHOST_ANSIBLE_USER }} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a9413a4 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +For the CI/CD pipelines [this website](https://spacelift.io/blog/github-actions-ansible) was used. + +The runner is installed using the playbook in the `opdracht-2` directory. \ No newline at end of file