Skip to content

Commit

Permalink
FIX: rename roles and add workflows (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoPlays committed Apr 25, 2024
1 parent 6428f6a commit 969a230
Show file tree
Hide file tree
Showing 22 changed files with 133 additions and 27 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/test-molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,112 @@ jobs:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
ansible_python_interpreter: "/usr/bin/python3"

upgrade-prep:
strategy:
matrix:
tests: [{ role: "upgrade-prep", test: "default" }]
fail-fast: false
concurrency: molecule-test-${{ matrix.tests.role }}-${{ matrix.tests.test }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install depencencies
run: |
pip install ansible==5.10.0
pip install molecule==5.0.1
pip install "molecule[docker.lint]"
pip install molecule-docker
pip install molecule-hetznercloud
pip install docker
pip install hcloud
ansible-galaxy collection install community.docker
- name: Install dependency for pipx
run: |
/opt/pipx/venvs/ansible-core/bin/python -m pip install ansible==5.10.0
/opt/pipx/venvs/ansible-core/bin/python -m pip install molecule==5.0.1
/opt/pipx/venvs/ansible-core/bin/python -m pip install "molecule[docker.lint]"
/opt/pipx/venvs/ansible-core/bin/python -m pip install molecule-docker
/opt/pipx/venvs/ansible-core/bin/python -m pip install molecule-hetznercloud
/opt/pipx/venvs/ansible-core/bin/python -m pip install docker
/opt/pipx/venvs/ansible-core/bin/python -m pip install hcloud
- name: Install ansible-lint
run: sudo apt-get install -y ansible-lint
- name: Molecule version
run: molecule --version
env:
ansible_python_interpreter: "/usr/bin/python3"
- name: Run tests
working-directory: ./controls/roles/${{ matrix.tests.role }}
run: molecule test -s ${{ matrix.tests.test }}
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
ansible_python_interpreter: "/usr/bin/python3"
# destroying is necessary when previous task failed and didn't clean up properly
- name: Destroy previous testing VMs
if: ${{ failure() || cancelled() }}
working-directory: ./controls/roles/${{ matrix.tests.role }}
run: molecule destroy -s ${{ matrix.tests.test }}
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
ansible_python_interpreter: "/usr/bin/python3"

update-package:
strategy:
matrix:
tests: [{ role: "update-package", test: "default" }]
fail-fast: false
concurrency: molecule-test-${{ matrix.tests.role }}-${{ matrix.tests.test }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install depencencies
run: |
pip install ansible==5.10.0
pip install molecule==5.0.1
pip install "molecule[docker.lint]"
pip install molecule-docker
pip install molecule-hetznercloud
pip install docker
pip install hcloud
ansible-galaxy collection install community.docker
- name: Install dependency for pipx
run: |
/opt/pipx/venvs/ansible-core/bin/python -m pip install ansible==5.10.0
/opt/pipx/venvs/ansible-core/bin/python -m pip install molecule==5.0.1
/opt/pipx/venvs/ansible-core/bin/python -m pip install "molecule[docker.lint]"
/opt/pipx/venvs/ansible-core/bin/python -m pip install molecule-docker
/opt/pipx/venvs/ansible-core/bin/python -m pip install molecule-hetznercloud
/opt/pipx/venvs/ansible-core/bin/python -m pip install docker
/opt/pipx/venvs/ansible-core/bin/python -m pip install hcloud
- name: Install ansible-lint
run: sudo apt-get install -y ansible-lint
- name: Molecule version
run: molecule --version
env:
ansible_python_interpreter: "/usr/bin/python3"
- name: Run tests
working-directory: ./controls/roles/${{ matrix.tests.role }}
run: molecule test -s ${{ matrix.tests.test }}
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
ansible_python_interpreter: "/usr/bin/python3"
# destroying is necessary when previous task failed and didn't clean up properly
- name: Destroy previous testing VMs
if: ${{ failure() || cancelled() }}
working-directory: ./controls/roles/${{ matrix.tests.role }}
run: molecule destroy -s ${{ matrix.tests.test }}
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
ansible_python_interpreter: "/usr/bin/python3"

restart-services:
strategy:
matrix:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
controls_install_path: "/opt/stereum"
- debug:
msg: "{{ stereum }}"
- name: "Include update_package"
- name: "Include update-package"
include_role:
name: "update_package"
name: "update-package"
vars:
packages_list: "git"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependency:
driver:
name: molecule_hetznercloud
platforms:
- name: "update_package--default--ubuntu-22.04"
- name: "update-package--default--ubuntu-22.04"
server_type: cx11
image: ubuntu-22.04
provisioner:
Expand Down
7 changes: 7 additions & 0 deletions controls/roles/update-package/molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include upgrade-prep"
include_role:
name: "upgrade-prep"
7 changes: 0 additions & 7 deletions controls/roles/update_package/molecule/default/playbook.yml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
controls_install_path: "/opt/stereum"
- debug:
msg: "{{ stereum }}"
- name: "Include upgrade_prep"
- name: "Include upgrade-prep"
include_role:
name: "upgrade_prep"
name: "upgrade-prep"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependency:
driver:
name: molecule_hetznercloud
platforms:
- name: "upgrade_prep--default--ubuntu-22.04"
- name: "upgrade-prep--default--ubuntu-22.04"
server_type: cx11
image: ubuntu-22.04
provisioner:
Expand Down
7 changes: 7 additions & 0 deletions controls/roles/upgrade-prep/molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include upgrade-prep"
include_role:
name: "upgrade-prep"
File renamed without changes.
7 changes: 0 additions & 7 deletions controls/roles/upgrade_prep/molecule/default/playbook.yml

This file was deleted.

14 changes: 7 additions & 7 deletions launcher/src/backend/NodeUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export class NodeUpdates {
}

/**
* runs the "upgrade_prep" role
* runs the "upgrade-prep" role
* executes do-release-upgrade
* runs the "switch_repos" role
* @returns {number}
*/
async upgrade() {
try {
log.info("Preparing for Upgrade to noble numbat ...");
await this.nodeConnection.runPlaybook("upgrade_prep", { stereum_role: "upgrade_prep" });
await this.nodeConnection.runPlaybook("upgrade-prep", { stereum_role: "upgrade-prep" });
log.info("Starting Upgrade to noble numbat ...");
const result = await this.nodeConnection.sshService.exec(
"do-release-upgrade -d -f DistUpgradeViewNonInteractive --allow-third-party"
Expand Down Expand Up @@ -180,23 +180,23 @@ export class NodeUpdates {
}

/**
* runs the "update_package" role, update of one or more specific packages
* runs the "update-package" role, update of one or more specific packages
* @param {string[]} packages - Array of Packagenames to upgrade
* @returns {number} - playbook runtime
*/
async updatePackage(packages) {
let packagesListString = packages.join(',');
let extraVars = {
stereum_role: "update_package",
stereum_role: "update-package",
packages_list: packagesListString,
};
try {
let before = this.getTimeStamp();
await this.nodeConnection.runPlaybook("update_package", extraVars);
await this.nodeConnection.runPlaybook("update-package", extraVars);
let after = this.getTimeStamp();
return after - before;
} catch (err) {
log.error("Error occurred running update_package:\n", err);
log.error("Error occurred running update-package:\n", err);
return 0;
}
}
Expand All @@ -214,7 +214,7 @@ export class NodeUpdates {

// Ensure the stdout ends with a newline character
const outputWithNewline = stdout.endsWith("\n") ? stdout : stdout + "\n";

// Split the output into lines
const lines = outputWithNewline.split("\n");

Expand Down

0 comments on commit 969a230

Please sign in to comment.