Configure Watchtower #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Configure Watchtower | |
on: | |
workflow_dispatch: | |
inputs: | |
TARGET_HOST: | |
type: string | |
required: true | |
jobs: | |
ansible: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Add SSH Keys | |
run: | | |
cat << EOF > devops-key | |
${{ secrets.SSH_PRIVATE_KEY }} | |
EOF | |
- name: Update devops private key permissions | |
run: | | |
chmod 400 devops-key | |
- name: Install Ansible | |
run: | | |
pip install ansible | |
- name: Adding or Override Ansible inventory File | |
run: | | |
cat << EOF > ./inventory.ini | |
[webservers] | |
${{ inputs.TARGET_HOST }} | |
EOF | |
- name: Adding or Override Ansible Config File | |
run: | | |
cat << EOF > ./ansible.cfg | |
[defaults] | |
ansible_python_interpreter='/usr/bin/python3' | |
deprecation_warnings=False | |
inventory=./inventory.ini | |
remote_user="root" | |
host_key_checking=False | |
private_key_file = ./devops-key | |
retries=2 | |
EOF | |
- name: Run main playbook | |
run: | | |
ANSIBLE_CONFIG=ansible.cfg ansible-playbook main.yml | |