Skip to content

Commit 0a4988d

Browse files
committed
define protected envs in common vars, improve lock_unlock_instances
1 parent ab80154 commit 0a4988d

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22

3-
- hosts: "{{ target_hosts | default('all') }}"
3+
- hosts: cluster
44
gather_facts: no
55
become: no
66
tasks:
77
- name: Lock/Unlock instances
88
openstack.cloud.server_action:
9-
action: "{{ server_action | default('lock') }}"
9+
action: "{{ appliances_server_action | default('lock') }}"
1010
server: "{{ inventory_hostname }}"
1111
delegate_to: localhost

ansible/adhoc/rebuild-via-slurm.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
- name: Unlock compute instances for rebuild
1212
vars:
13-
server_action: unlock
14-
target_hosts: compute
15-
ansible.builtin.import_playbook: lock_unlock_instances.yml
13+
appliances_server_action: unlock
14+
ansible.builtin.command: ansible-playbook --limit compute adhoc/lock_unlock_instances.yml
1615

1716
- hosts: login
1817
run_once: true

ansible/safe-env.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
- hosts: localhost
33
gather_facts: no
44
become: no
5-
vars:
6-
protected_environments:
7-
- prd
85
tasks:
96
- name: Confirm continuing if using production environment
107
ansible.builtin.pause:
@@ -17,6 +14,6 @@
1714
Do you really want to continue (yes/no)?
1815
register: env_confirm_safe
1916
when:
20-
- appliances_environment_name in protected_environments
21-
- not (prd_continue | default(false) | bool)
17+
- appliances_environment_name in appliances_protected_environments
18+
- not (appliances_protected_environment_autoapprove | default(false) | bool)
2219
failed_when: not (env_confirm_safe.user_input | bool)

ansible/site.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
- ansible.builtin.import_playbook: safe-env.yml
44

5-
- name: Lock all instances
6-
vars:
7-
server_action: lock
8-
target_hosts: all
9-
ansible.builtin.import_playbook: adhoc/lock_unlock_instances.yml
5+
- name: Lock cluster instances
6+
ansible.builtin.command: ansible-playbook adhoc/lock_unlock_instances.yml
107

118
- name: Run pre.yml hook
129
vars:

environments/common/inventory/group_vars/all/defaults.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ansible_user: rocky
44
appliances_repository_root: "{{ lookup('env', 'APPLIANCES_REPO_ROOT') }}"
55
appliances_environment_root: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}"
66
appliances_environment_name: "{{ appliances_environment_root | basename | regex_replace('\\W+', '') }}" # [a-zA-Z0-9_] only
7+
appliances_protected_environments:
8+
- prd
79
appliances_cockpit_state: absent # RHEL cockpit installed but not enabled in genericcloud images; appliance defaults to removing it
810
# appliances_state_dir: # define an absolute path here to use for persistent state: NB: This is defined as /var/lib/state in inventory by the default Terraform
911
appliances_mode: configure

0 commit comments

Comments
 (0)