Skip to content

Testing change!

Testing change! #9

Workflow file for this run

name: Run Ansible Playbook
on:
push:
branches:
- main # or your desired branch
jobs:
run-playbook:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Ansible and sshpass
run: |
sudo apt update
sudo apt install -y ansible openssh-client sshpass # Install sshpass for password-based SSH authentication
- name: Create dynamic inventory.ini
run: |
mkdir -p ansible # Ensure the ansible directory exists
echo "[vps]" > ansible/inventory.ini
echo "${{ secrets.VPS_IP }}" >> ansible/inventory.ini
echo "[vps:vars]" >> ansible/inventory.ini
echo "ansible_ssh_user=${{ secrets.ANSIBLE_SSH_USER }}" >> ansible/inventory.ini
echo "ansible_ssh_pass=${{ secrets.VPS_SSH_PASSWORD }}" >> ansible/inventory.ini
- name: Add VPS SSH key to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.VPS_IP }} >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Run Ansible playbook with password
run: ansible-playbook ansible/playbook.yml -i ansible/inventory.ini