Skip to content

Commit

Permalink
better organisation of actions
Browse files Browse the repository at this point in the history
  • Loading branch information
martindemko committed Jan 16, 2025
1 parent 0f4c41c commit 6e9992a
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 26 deletions.
26 changes: 26 additions & 0 deletions .github/actions/run-infrastructure-playbook/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! vim: ts=2 expandtab:

name: infrastructure-playbook

runs:
using: 'composite'
steps:
- name: Make SSH connection
shell: bash
run: |
mkdir -p $HOME/.ssh
install -m 600 -D /dev/null $HOME/.ssh/id_rsa
echo "$SSH_PRIVATE_KEY" > $HOME/.ssh/id_rsa
ssh -f -o StrictHostKeyChecking=no $TARGET_USER@$TARGET_HOSTNAME hostname
- name: Install Ansible requirements
shell: bash
run: ansible-galaxy install -p roles -r requirements.yml

- name: Create vault password
shell: bash
run: echo "$VAULT_PASSWORD" >.vault-password.txt

- name: Run galaxy.yaml playbook
shell: bash
run: ansible-playbook -vvv --limit $TARGET_HOSTNAME galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! vim: ts=2 expandtab:

name: install-tools
name: install-tools-playbook

runs:
using: 'composite'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#! vim: ts=2 expandtab:

name: run-ansible-playbook
name: test-tools-playbook

runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Make SSH connection
shell: bash
run: |
Expand All @@ -16,26 +13,10 @@ runs:
echo "$SSH_PRIVATE_KEY" > $HOME/.ssh/id_rsa
ssh -f -o StrictHostKeyChecking=no $TARGET_USER@$TARGET_HOSTNAME hostname
- name: Install Ansible requirements
shell: bash
run: ansible-galaxy install -p roles -r requirements.yml

- name: Create vault password
shell: bash
run: echo "$VAULT_PASSWORD" >.vault-password.txt

- name: Run galaxy.yaml playbook
shell: bash
run: ansible-playbook -vvv --limit $TARGET_HOSTNAME galaxy.yml

- name: Sleep for 3 minutes
shell: bash
run: sleep 180s

- name: Run galaxy_tools.yaml playbook
shell: bash
run: ansible-playbook -vvv --limit $TARGET_HOSTNAME galaxy_tools.yml

- name: Run galaxy_tests.yaml playbook
shell: bash
run: ansible-playbook -vvv --limit $TARGET_HOSTNAME galaxy_tests.yml
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/qa1-complete-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! vim: ts=2 expandtab:

name: qa1-complete-deploy

# TODO: run automatically on push to main
on: [ workflow_dispatch ]

jobs:
call-common:
runs-on: ubuntu-latest
steps:
- name: Checkout actions
uses: actions/checkout@v3

- name: Call run-infrastructure-playbook action
uses: ./.github/actions/run-infrastructure-playbook
env:
TARGET_HOSTNAME: galaxy-qa1.galaxy.cloud.e-infra.cz
TARGET_USER: debian
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD_QA1 }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_QA1 }}

- name: Sleep for 3 minutes
shell: bash
run: sleep 180s

- name: Call run-install-tools-playbook action
uses: ./.github/actions/run-install-tools-playbook
env:
TARGET_HOSTNAME: galaxy-qa1.galaxy.cloud.e-infra.cz
TARGET_USER: debian
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD_QA1 }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_QA1 }}

- name: Call run-test-tools-playbook action
uses: ./.github/actions/run-test-tools-playbook
env:
TARGET_HOSTNAME: galaxy-qa1.galaxy.cloud.e-infra.cz
TARGET_USER: debian
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD_QA1 }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_QA1 }}
22 changes: 22 additions & 0 deletions .github/workflows/qa1-install-tools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! vim: ts=2 expandtab:

name: qa1-install-tools

# TODO: run automatically on push to main
on: [ workflow_dispatch ]

jobs:
call-common:
runs-on: ubuntu-latest
steps:
- name: Checkout actions
uses: actions/checkout@v3

- name: Call run-install-tools-playbook action
uses: ./.github/actions/run-install-tools-playbook
env:
TARGET_HOSTNAME: galaxy-qa1.galaxy.cloud.e-infra.cz
TARGET_USER: debian
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD_QA1 }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_QA1 }}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! vim: ts=2 expandtab:

name: deploy-qa1-ansible
name: qa1-test-tools

# TODO: run automatically on push to main
on: [ workflow_dispatch ]
Expand All @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout actions
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Call run-ansible-playbook action
uses: ./.github/actions/run-ansible-playbook
- name: Call run-test-tools-playbook action
uses: ./.github/actions/run-test-tools-playbook
env:
TARGET_HOSTNAME: galaxy-qa1.galaxy.cloud.e-infra.cz
TARGET_USER: debian
Expand Down
2 changes: 1 addition & 1 deletion galaxy_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
cmd: /tmp/ephemeris/bin/shed-tools install -g https://{{ inventory_hostname }} -a {{ api_key }} -t /tmp/master_tool_list.yaml
when: copy_tools_from

- name: Install local tools
- name: Install instance specific tools
local_action:
module: ansible.builtin.shell
cmd: /tmp/ephemeris/bin/shed-tools install -g https://{{ inventory_hostname }} -a {{ api_key }} -t files/{{ inventory_hostname }}/tool_list.yaml

0 comments on commit 6e9992a

Please sign in to comment.