Provision demo-prod (tag: users) #221
Workflow file for this run
This file contains hidden or 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: Provision Infrastructure | |
| run-name: "Provision ${{ inputs.environment }} (tag: ${{ inputs.tags }})" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Infrastructure to provision' | |
| required: true | |
| default: 'demo' | |
| type: choice | |
| options: | |
| - demo-prod | |
| tags: | |
| description: 'Tags to apply to the provisioned resources' | |
| required: true | |
| default: all | |
| type: choice | |
| options: | |
| - all | |
| - updates | |
| - users | |
| - backup | |
| - application | |
| - tools | |
| - fail2ban | |
| - decrypt-on-boot | |
| - checks | |
| - containerd-setup | |
| - k8s | |
| - system-preparation | |
| jobs: | |
| provision: | |
| runs-on: | |
| - self-hosted | |
| - ${{ inputs.environment }} | |
| - node | |
| environment: ${{ inputs.environment }} | |
| steps: | |
| - name: Set variables for ansible | |
| id: ansible-variables | |
| run: | | |
| JSON_WITH_NEWLINES=$(cat<<EOF | |
| ${{ toJSON(env) }} | |
| EOF) | |
| JSON_WITHOUT_NEWLINES=$(echo $JSON_WITH_NEWLINES | jq -R -c .) | |
| echo "EXTRA_VARS=$JSON_WITHOUT_NEWLINES" >> $GITHUB_OUTPUT | |
| env: | |
| encrypted_disk_size: ${{ vars.DISK_SPACE }} | |
| disk_encryption_key: ${{ secrets.ENCRYPTION_KEY }} | |
| k8s_runner_token: ${{ secrets.GH_TOKEN }} | |
| repository: ${{ github.repository }} | |
| k8s_cluster_env: ${{ inputs.environment }} | |
| docker_username: ${{ secrets.DOCKER_USERNAME }} | |
| docker_password: ${{ secrets.DOCKER_TOKEN }} | |
| smtp_host: ${{ secrets.SMTP_HOST }} | |
| smtp_port: ${{ secrets.SMTP_PORT }} | |
| smtp_user: ${{ secrets.SMTP_USERNAME }} | |
| smtp_secure: ${{ secrets.SMTP_SECURE }} | |
| # FIXME: Make this field configurable via secrets | |
| smtp_from: "team@opencrvs.org" | |
| smtp_password: ${{ secrets.SMTP_PASSWORD }} | |
| alert_email: ${{ secrets.ALERT_EMAIL }} | |
| - name: checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Run Ansible Playbook | |
| uses: dawidd6/action-ansible-playbook@v4 | |
| env: | |
| ANSIBLE_PERSISTENT_COMMAND_TIMEOUT: 10 | |
| ANSIBLE_SSH_TIMEOUT: 10 | |
| ANSIBLE_SSH_RETRIES: 5 | |
| with: | |
| requirements: galaxy-requirements.yml | |
| playbook: playbook.yml | |
| directory: ./infrastructure/server-setup | |
| # Add --verbose to get more output | |
| options: |- | |
| --inventory inventory/${{ inputs.environment }}.yml | |
| ${{ inputs.tags != 'all' && format('--tags={0}', inputs.tags) || '' }} | |
| --extra-vars ""${{ steps.ansible-variables.outputs.EXTRA_VARS }}"" |