Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: using skip install on a subset of a group of hosts #252

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

alkinks
Copy link
Contributor

@alkinks alkinks commented Nov 30, 2023

If, for a group of hosts you have <role name>_skip_install set to true for a subset of those hosts & the playbook runs on one of this subset first, the run_once means the task to get the binary checksums is skipped, and subsequent tasks will fail.

Running molecule converge on the current chrony_exporter role, with chrony_exporter_skip_install=true I get this output (truncated).

TASK [chrony_exporter : Discover latest version] *******************************
skipping: [almalinux-8] => {"changed": false, "skip_reason": "Conditional result was False"}

TASK [chrony_exporter : Get checksum list from github] *************************
skipping: [almalinux-8] => {"changed": false, "skip_reason": "Conditional result was False"}

TASK [chrony_exporter : Get checksum for amd64] ********************************
skipping: [almalinux-8] => {"changed": false, "skip_reason": "Conditional result was False"}
fatal: [almalinux-9]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [centos-7]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [centos-stream-8]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [debian-10]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [debian-11]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [fedora-37]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [fedora-38]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [ubuntu-20.04]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}
fatal: [ubuntu-22.04]: FAILED! => {"msg": "'__chrony_exporter_checksums' is undefined"}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
almalinux-8                : ok=8    changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
almalinux-9                : ok=8    changed=0    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0
centos-7                   : ok=8    changed=0    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0
centos-stream-8            : ok=8    changed=0    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0
centos-stream-9            : ok=8    changed=0    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0
debian-10                  : ok=9    changed=0    unreachable=0    failed=1    skipped=5    rescued=0    ignored=0
debian-11                  : ok=9    changed=0    unreachable=0    failed=1    skipped=5    rescued=0    ignored=0
fedora-37                  : ok=8    changed=0    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0
fedora-38                  : ok=8    changed=0    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0
ubuntu-20.04               : ok=9    changed=0    unreachable=0    failed=1    skipped=5    rescued=0    ignored=0
ubuntu-22.04               : ok=9    changed=0    unreachable=0    failed=1    skipped=5    rescued=0    ignored=0

On my branch you get this (truncated):

TASK [chrony_exporter : Discover latest version] *******************************
skipping: [almalinux-8]

TASK [chrony_exporter : Get chrony_exporter binary checksum] *******************
skipping: [almalinux-8]
included: /net/homes/akingsto/git/prometheus.prometheus/roles/chrony_exporter/tasks/get_checksum.yml for almalinux-9, centos-7, centos-stream-8, centos-stream-9, debian-10, debian-11, fedora-37, fedora-38, ubuntu-20.04, ubuntu-22.04

TASK [chrony_exporter : Get checksum list from github] *************************
ok: [almalinux-9]

TASK [chrony_exporter : Get checksum for amd64] ********************************
skipping: [almalinux-9] => (item=05e59b8a952b80f03ff376f0f63a6d7c9566bfbc96d5cd4c70e03e4e216628a2  chrony_exporter-0.6.1.linux-386.tar.gz) 
ok: [almalinux-9] => (item=d820ffa11af32c2af5f9cd6598e7046fd0f7dc2929f4487bd71aa10d1d635710  chrony_exporter-0.6.1.linux-amd64.tar.gz)


PLAY RECAP *********************************************************************
almalinux-8                : ok=14   changed=0    unreachable=0    failed=0    skipped=11   rescued=0    ignored=0
almalinux-9                : ok=17   changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
centos-7                   : ok=16   changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
centos-stream-8            : ok=16   changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
centos-stream-9            : ok=16   changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
debian-10                  : ok=17   changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
debian-11                  : ok=17   changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
fedora-37                  : ok=16   changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
fedora-38                  : ok=16   changed=0    unreachable=0    failed=0    skipped=9    rescued=0    ignored=0
ubuntu-20.04               : ok=17   changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0
ubuntu-22.04               : ok=17   changed=0    unreachable=0    failed=0    skipped=8    rescued=0    ignored=0

Which runs the download of the checksums once on a host which isn't skipped.

alkinks and others added 12 commits November 30, 2023 19:05
When a role skip_install variable is set to true for some,
but not all hosts, it is possible for the checksums to not get downloaded,
and the tasks will fail. This puts those tasks in an included task file

Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: ScarletBlizzard <61126210+ScarletBlizzard@users.noreply.github.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
…test molecule wrapper

Signed-off-by: gardar <gardar@users.noreply.github.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: gardar <gardar@users.noreply.github.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: gardar <gardar@users.noreply.github.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: gardar <gardar@users.noreply.github.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: ScarletBlizzard <61126210+ScarletBlizzard@users.noreply.github.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: prombot <prometheus-team@googlegroups.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Nikolay Asenov <asenov.nikolay98@gmail.com>
Signed-off-by: Ben Kochie <superq@gmail.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
wookietreiber and others added 12 commits November 30, 2023 19:05
Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
…sses

Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
…esses

Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
…eflight

this is for consistency with the other roles' preflight asserts for when
prometheus itself finally supports multiple web listen addresses

Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
…s in preflight

this is for consistency with the other roles' preflight asserts for when the
exporter itself finally supports multiple web listen addresses

Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
… in preflight

this is for consistency with the other roles' preflight asserts for when the
exporter itself finally supports multiple web listen addresses

Signed-off-by: Christian Krause <christian.krause@idiv.de>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: Andrew Kingston <andrew.kingston@framestore.com>
Signed-off-by: alkinks <124047745+alkinks@users.noreply.github.com>
@github-actions github-actions bot added bugfix and removed bugfix labels Nov 30, 2023
@alkinks alkinks marked this pull request as ready for review November 30, 2023 19:09
@alkinks
Copy link
Contributor Author

alkinks commented Nov 30, 2023

There is a similar issue with the check for the latest versions. If you wanted "latest" version for any host other than the first host the playbook gets run on, then the role would skip determining what the latest version is.

@github-actions github-actions bot added bugfix and removed bugfix labels Jan 16, 2024
@alkinks
Copy link
Contributor Author

alkinks commented Jan 16, 2024

Adding issue: #279

@SuperQ SuperQ requested a review from gardar February 12, 2024 06:55
Copy link
Member

@gardar gardar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tried this change yet but does moving the task from a block to include_tasks really work?
I would think that it would either end with the same result as the block or run the checksum fetch for all of the hosts and bypassing the run_once

@alkinks
Copy link
Contributor Author

alkinks commented Feb 13, 2024

I have not tried this change yet but does moving the task from a block to include_tasks really work? I would think that it would either end with the same result as the block or run the checksum fetch for all of the hosts and bypassing the run_once

This does seem to work as is intended.

I set up the molecule provisioner like so:

provisioner:
  playbooks:
    converge: "${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/converge.yml"
  inventory:
    host_vars:
      almalinux-8:
        alertmanager_skip_install: true
      almalinux-9:
        alertmanager_skip_install: true
      centos-7:
        alertmanager_skip_install: true
      fedora-38:
        alertmanager_skip_install: true

Then ran converge for the alertmanager role:

molecule converge  -- --diff -v
.
.
.
TASK [../roles/alertmanager : Discover latest version] *************************
skipping: [almalinux-8] => {"changed": false, "skip_reason": "Conditional result was False"}

TASK [../roles/alertmanager : Get alertmanager binary checksum] ****************
skipping: [almalinux-8] => {"changed": false, "skip_reason": "Conditional result was False"}
skipping: [almalinux-9] => {"changed": false, "skip_reason": "Conditional result was False"}
skipping: [centos-7] => {"changed": false, "skip_reason": "Conditional result was False"}
skipping: [fedora-38] => {"changed": false, "skip_reason": "Conditional result was False"}
included: /net/homes/akingsto/git/prometheus.prometheus/roles/alertmanager/tasks/get_checksum.yml for centos-stream-8, centos-stream-9, debian-10, debian-11, fedora-37, ubuntu-20.04, ubuntu-22.04

TASK [../roles/alertmanager : Get checksum list] *******************************
ok: [centos-stream-8] => {"ansible_facts": {"__alertmanager_checksums": ["3dce2314b956bdf39599912c28ebb79aac533e4ceb36d608a3efbdd109bc5912  alertmanager-0.26.0.darwin-amd64.tar.gz", 
279265678d4052f4d398b1603c610e1937074c795ea6c9c348a9da2efdb87748  alertmanager-0.26.0.darwin-arm64.tar.gz", 
511f8f74a9deef04f8872ce35e80e419e6f0b1d0a7be075d9522725a8a52b3c7  alertmanager-0.26.0.dragonfly-amd64.tar.gz", 
a6ed1691f520468a9bc58580d4ab45a85460b3255f0399433ecf5cda4b5f4569  alertmanager-0.26.0.freebsd-386.tar.gz", 
8b1b0a51dc8dc80ed0d2a6d2ce9e5b03c699cffd294e05f470b72bcfa483f8a2  alertmanager-0.26.0.freebsd-amd64.tar.gz", 
1b01e12ee84ac9f17de909eaab8680fd0d3e6e4f300396c02415d640f6249337  alertmanager-0.26.0.freebsd-arm64.tar.gz", 
e94b011e48a5fc44e6571048a17d5a51e0dc4f2ff2316f08121cb968da65cfa4  alertmanager-0.26.0.freebsd-armv6.tar.gz", 
067b9441d4b52238d571aa5c705ccc8a97005cd3d57ec60b3d28c7688552e77a  alertmanager-0.26.0.freebsd-armv7.tar.gz", 
9628a016af5247278d9df42fb6c45e7afbf673df92a5b5c4cb6953e087014e94  alertmanager-0.26.0.illumos-amd64.tar.gz", 
bd002d98e0b2b84aa5db335711f44bcf9df8072bb97cd7ec7cc6e1a3231f6111  alertmanager-0.26.0.linux-386.tar.gz", 
abd73e2ee6bf67d3888699660abbecba7b076bf1f9459a3a8999d493b149ffa6  alertmanager-0.26.0.linux-amd64.tar.gz", 
f65969661821570929ad34cf64e034fe72c8e014855d244321c67a0c3ce3fc08  alertmanager-0.26.0.linux-arm64.tar.gz", 
f7f5dc4b2c5edbb5d12c16076dcba3c1d60395ef061a0a229e08661a39784abf  alertmanager-0.26.0.linux-armv5.tar.gz", 
dedb691e494d7670b78728d70ded8e78d4f1fea1c00d384a793ad6040c6af853  alertmanager-0.26.0.linux-armv6.tar.gz", 
1a88a94c1f6cce900f49daba6142a5900afc92619ce98864663338d74bcf1685  alertmanager-0.26.0.linux-armv7.tar.gz", 716256ea7fc831fc68cb6beff6d90e59c3dd759cdbca8e2f5886cbee10794b31  alertmanager-0.26.0.linux-mips.tar.gz", 
9ed49f4959609d41fc6b2739b6ef68bf1e717fcf39c439241fda31d63752606b  alertmanager-0.26.0.linux-mips64.tar.gz", 
354d9dcaaf528ef8bfec86ad66a7514b4198610dc622faa6cbb5dd19afab6e65  alertmanager-0.26.0.linux-mips64le.tar.gz", 
78510fcf2dc3b84b8bd28703a830e9be656b8b211b1f0a1b8ce05e272a2d3f85  alertmanager-0.26.0.linux-mipsle.tar.gz", 
40d46168465ed1a9275d6684486a01bff8b663c6e974f4f85042e01d9ef62015  alertmanager-0.26.0.linux-ppc64.tar.gz", 
5ccbb4d864fa3785f75667ce59ef2b6ca5794d8c954f56a58551a3175b701928  alertmanager-0.26.0.linux-ppc64le.tar.gz", 
2e8f10be68680045308f77f344f19a08d939941a9286f2f4952ef9a21af9e593  alertmanager-0.26.0.linux-s390x.tar.gz", 
49d5e4cb2995fd2270cb512f93a0bc4c598d9acbe1caf16c3c5106ba391b39bd  alertmanager-0.26.0.netbsd-386.tar.gz", 
fbb82c65fb1a2bb5a1641854d6f1912b33d3036025a1ac2dd9786e999e2787f4  alertmanager-0.26.0.netbsd-amd64.tar.gz", 
e3d1e953cc85f3ae357f878716201584054912030e153d0a179c25e982c11733  alertmanager-0.26.0.netbsd-arm64.tar.gz", 
d0b3ec50d9dbce3d60b6efac67e0b9350d759e835c2b26f881e632080a1f1d90  alertmanager-0.26.0.netbsd-armv6.tar.gz", 
8736a2b34f9b761a283246a2c1750c797f3ad19dadb05cc13a6f364e77c542e5  alertmanager-0.26.0.netbsd-armv7.tar.gz", 
9c977a0bb2ca368b247f7bb5eeca0055619cb0ece170f41c2d0167a9f4f7a087  alertmanager-0.26.0.openbsd-386.tar.gz", 
ea20b42224694b9b1788e5de8eba6c4f633381c936ba9c614f7666ac02bb2754  alertmanager-0.26.0.openbsd-amd64.tar.gz", 
de4b79bd913456b7dc4ca2a5ac16ae2a8337a411b750a9260394632abca0c735  alertmanager-0.26.0.openbsd-arm64.tar.gz", 
4ba50ede07eaf17a84582f13af91b4aae83788c1cd63686668a28b60f1242994  alertmanager-0.26.0.openbsd-armv7.tar.gz", 
85d6619b0a16d039647865a05d2eff22c20258120900f19451e95426c229b4de  alertmanager-0.26.0.windows-386.tar.gz", 
4d8e9978d3c714f64a7ff76054325cc2cfcc78c1722c97093687b629e5f3bbac  alertmanager-0.26.0.windows-386.zip", 
dc26fc8f9ef8b3801069803f50ae182c8b84620de3a94e0adc90c0669bc5af76  alertmanager-0.26.0.windows-amd64.tar.gz", 
4f170342f31f27ac1a1c7b1cd5df928a184eed49f65a39327c00aa3927a6e020  alertmanager-0.26.0.windows-amd64.zip", 
37f210b6370c87083f9a9fc2af98a79c2deb35b78513b72848fd20f1ad5048a0  alertmanager-0.26.0.windows-arm64.tar.gz", 
f6694fb511ade5ab467b0b2ad15eb01e1aa973f822e3fadaf6b1a7b5f7245e0c  alertmanager-0.26.0.windows-arm64.zip", 
e8f956900edca20f2c33bca1d46458a45c519158cbc330acf232ad2742c45e49  alertmanager-web-ui-0.26.0.tar.gz"]}, "attempts": 1, 
 changed": false}

TASK [../roles/alertmanager : Get checksum for amd64] **************************

You can see the Discover latest version task (which I haven't updated to include a task file) runs once on almalinux-8, but doesn't do anything because almalinux-8 gets skipped.

Then the Get alertmanager binary checksum task doesn't include the get_checksum.yml task file for the skipped hosts, but does for all the other hosts.

The task set to run_once - Get checksum list runs on the first host out of those not skipped, and then not on any other host.

@github-actions github-actions bot added bugfix and removed bugfix labels Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants