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

ENH: require config mode in order to run the provisioning playbook #16

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

ZLLentz
Copy link
Member

@ZLLentz ZLLentz commented Mar 15, 2024

Description

This makes the provisioning workflow refuse to proceed if the PLC is not in config mode, for example if it is in run mode or some invalid or error mode.

Motivation and Context

From feedback in the TcBSD internal review: this is a simple way to stop ourselves from changing PLC configurations on active, running PLCs.

How Has This Been Tested?

Interactively on plc-tst-bsd2:

When in run mode:

$ ./scripts/provision_plc.sh plc-tst-bsd2
TcBSD key is registered with ssh agent
BECOME password:

PLAY [plc-tst-bsd2] **************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Verify connectivity with ping] *********************************************************************************************************************************************************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Run PLC mode command] ******************************************************************************************************************************************************************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Assert that PLC is in CONFIG mode] *****************************************************************************************************************************************************************************************************************************************************
fatal: [plc-tst-bsd2]: FAILED! => {"assertion": false, "changed": false, "evaluated_to": false, "msg": "PLC is in RUN mode! Abort!"}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************************
plc-tst-bsd2               : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

When in config mode:

$ ./scripts/provision_plc.sh plc-tst-bsd2
TcBSD key is registered with ssh agent
BECOME password:

PLAY [plc-tst-bsd2] ******************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Verify connectivity with ping] *************************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Run PLC mode command] **********************************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Assert that PLC is in CONFIG mode] *********************************************************************************************************************
ok: [plc-tst-bsd2]

TASK [Enable FreeBSD packages] *******************************************************************************************************************************
skipping: [plc-tst-bsd2]

(continues)

I also verified that this check works from a fresh install.

Where Has This Been Documented?

https://confluence.slac.stanford.edu/display/PCDS/TcBSD+Ansible+Workflows

Pre-merge checklist

@ZLLentz ZLLentz marked this pull request as ready for review March 15, 2024 00:27
@ZLLentz ZLLentz requested review from ghalym and nrwslac March 15, 2024 15:49
Copy link

@nrwslac nrwslac left a comment

Choose a reason for hiding this comment

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

Took some time to look through the ansible docs about playbooks, plays, and tasks. This looks correct to me.

Copy link

@ghalym ghalym left a comment

Choose a reason for hiding this comment

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

lgtm.

@ZLLentz ZLLentz merged commit fe0515d into pcdshub:master Mar 15, 2024
1 check passed
@ZLLentz ZLLentz deleted the enh_cfg_req branch March 15, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants