Run Ansible execution environment #6
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: Run Ansible execution environment | |
on: | |
workflow_dispatch | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
CONTAINER_REGISTRY_URL: ghcr.io | |
EE_BASELINE_IMAGE_NAME: ee-baseline | |
EE_AZURE_IMAGE_NAME: ee-azure | |
MACHINE_ROLE: testvm | |
jobs: | |
ee-run: | |
runs-on: ubuntu-latest | |
environment: test | |
steps: | |
- name: Log into Azure | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${CONTAINER_REGISTRY_URL} -u $ --password-stdin | |
- name: Construct & check the inventory | |
run: | | |
mkdir -p ${GITHUB_WORKSPACE}/${MACHINE_ROLE}/inventory/ | |
cat > ${GITHUB_WORKSPACE}/${MACHINE_ROLE}/inventory/azure_rm.yml <<EOF | |
plugin: azure.azcollection.azure_rm | |
auth_source: auto | |
EOF | |
- name: Construct & check the playbook | |
run: | | |
mkdir -p ${GITHUB_WORKSPACE}/${MACHINE_ROLE}/project/ | |
cat > ${GITHUB_WORKSPACE}/${MACHINE_ROLE}/project/playbook.yml <<EOF | |
- name: Testing Ansible SSH connectivity | |
hosts: all | |
tasks: | |
- name: Ping the thing! | |
ping: | |
EOF | |
- name: Test run the Azure execution environment image | |
run: | | |
docker run --rm -u root -v ${GITHUB_WORKSPACE}/${MACHINE_ROLE}:/runner -v /home/runner/.azure/:/root/.azure/ -e RUNNER_PLAYBOOK=playbook.yml -e ANSIBLE_INVENTORY=/runner/inventory ${CONTAINER_REGISTRY_URL}/${GITHUB_ACTOR}/${EE_AZURE_IMAGE_NAME} ansible-inventory --graph | |
# docker run --rm -u root -v ${PWD}/${MACHINE_ROLE}:/runner -v /home/runner/.azure/:/root/.azure/ -e RUNNER_PLAYBOOK=playbook.yml -e ANSIBLE_INVENTORY=/runner/inventory ${CONTAINER_REGISTRY_URL}/ansible/${EE_AZURE_IMAGE_NAME} ansible-runner run /runner |