Skip to content

Commit

Permalink
sap_general_preconfigure: Use only one tag for running all configurat…
Browse files Browse the repository at this point in the history
…ion steps

Examples for using tags: See README.md.

Relates to: sap-linuxlab#342.

Signed-off-by: Bernd Finger <[email protected]>
  • Loading branch information
berndfinger committed Feb 16, 2024
1 parent c2cd1a4 commit 7e08d48
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 48 deletions.
27 changes: 12 additions & 15 deletions roles/sap_general_preconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,47 +339,44 @@ sap_general_preconfigure_db_group_name: dba
With the following tags, the role can be called to perform certain activities only:
- tag `sap_general_preconfigure_installation`: Perform only the installation tasks
- tag `sap_general_preconfigure_configuration`: Perform only the configuration tasks
- tag `sap_general_preconfigure_configuration_all_steps`: Perform all configuration tasks
- tag `sap_general_preconfigure_3108316_03`: Perform only the tasks(s) related to this step of the SAP note.
- tag `sap_general_preconfigure_etc_hosts`: Perform only the tasks(s) related to this step. This step might be one of multiple
configuration activities of a SAP note. Also this step might be valid for multiple RHEL major releases.

Sample call for only performing all installation and configuration tasks. This is the default behavior. If no tag is specified, all
installation and configuration tasks are enabled:
Sample call for only performing all installation and configuration tasks (sample playbook name sap.yml, see the next section for
an example). This is the default behavior. If no tag is specified, all installation and configuration tasks are enabled:
```
# ansible-playbook sap-general-preconfigure.yml
# ansible-playbook sap.yml
```

Sample call for only performing all installation tasks:
```
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_installation
# ansible-playbook sap.yml --tags=sap_general_preconfigure_installation
```

Sample call for only performing all configuration tasks. The tag sap_general_preconfigure_configuration is needed to only use
the configuration tasks, and the tag sap_general_preconfigure_configuration_all_steps activates each individual configuration task. Both
need to be enabled for running all the configuration tasks:
Sample call for only performing all configuration tasks:
```
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_configuration,sap_general_preconfigure_configuration_all_steps
# ansible-playbook sap.yml --tags=sap_general_preconfigure_configuration
```

Sample call for only verifying and modifying the /etc/hosts file:
```
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_configuration,sap_general_preconfigure_etc_hosts
# ansible-playbook sap.yml --tags=sap_general_preconfigure_etc_hosts
```

Sample call for performing all configuration steps except verifying and modifying the /etc/hosts file:
```
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_configuration,sap_general_preconfigure_configuration_all_steps --skip_tags=sap_general_preconfigure_etc_hosts
# ansible-playbook sap.yml --tags=sap_general_preconfigure_configuration --skip_tags=sap_general_preconfigure_etc_hosts
```

Sample call for only performing the configuration actitvities related to step 2 (SELinux settings) of SAP note 3108316:
Sample call for only performing the configuration actitvities related to step 2 (SELinux settings) of SAP note 3108316 (RHEL 9 specific):
```
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_configuration,sap_general_preconfigure_3108316_02
# ansible-playbook sap.yml --tags=sap_general_preconfigure_3108316_02
```

Sample call for performing all configuration actitvities except those related to step 2 (SELinux settings) of SAP note 3108316:
Sample call for performing all configuration actitvities except those related to step 2 (SELinux settings) of SAP note 3108316 (RHEL 9 specific):
```
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_configuration,sap_general_preconfigure_configuration_all_steps --skip_tags=sap_general_preconfigure_3108316_02
# ansible-playbook sap-general-preconfigure.yml --tags=sap_general_preconfigure_configuration --skip_tags=sap_general_preconfigure_3108316_02
```

## Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
- name: Assert - List required SAP Notes
ansible.builtin.debug:
var: __sap_general_preconfigure_sapnotes_versions | difference([''])
tags:
- always

- name: Gather service facts
ansible.builtin.service_facts:
tags:
- always

- name: Assert - Include configuration actions for required sapnotes
ansible.builtin.include_tasks: "sapnote/assert-{{ sap_note_line_item.number }}.yml"
with_items: "{{ __sap_general_preconfigure_sapnotes_versions | difference(['']) }}"
loop_control:
loop_var: sap_note_line_item
tags:
- always
18 changes: 16 additions & 2 deletions roles/sap_general_preconfigure/tasks/RedHat/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- name: Configure - List required SAP Notes
ansible.builtin.debug:
var: __sap_general_preconfigure_sapnotes_versions | difference([''])
tags:
- always

- name: Configure - Set directory variables for setting SELinux file contexts
ansible.builtin.set_fact:
Expand All @@ -16,11 +18,19 @@
target: "{{ line_item }}(/.*)?"
setype: 'usr_t'
when: sap_general_preconfigure_modify_selinux_labels
tags:
- sap_general_preconfigure_3108316_02
- sap_general_preconfigure_2772999_02
- sap_general_preconfigure_selinux

- name: Configure - Display directory variable
ansible.builtin.debug:
var: sap_general_preconfigure_fact_targets_setypes
when: sap_general_preconfigure_modify_selinux_labels
tags:
- sap_general_preconfigure_3108316_02
- sap_general_preconfigure_2772999_02
- sap_general_preconfigure_selinux

- name: Configure - Create directories
ansible.builtin.file:
Expand All @@ -33,6 +43,11 @@
loop_control:
loop_var: line_item
when: sap_general_preconfigure_create_directories or sap_general_preconfigure_modify_selinux_labels
tags:
- sap_general_preconfigure_create_directories
- sap_general_preconfigure_3108316_02
- sap_general_preconfigure_2772999_02
- sap_general_preconfigure_selinux

- name: Configure - Include configuration actions for required sapnotes
ansible.builtin.include_tasks:
Expand All @@ -41,5 +56,4 @@
loop_control:
loop_var: sap_note_line_item
tags:
- sap_general_preconfigure_configuration
- sap_general_preconfigure_configuration_all_steps
- always
31 changes: 11 additions & 20 deletions roles/sap_general_preconfigure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
ansible.builtin.debug:
var: role_path
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Include OS specific vars, specific
ansible.builtin.include_vars: '{{ item }}'
Expand All @@ -14,8 +13,7 @@
- '{{ ansible_distribution.split("_")[0] }}_{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_os_family }}.yml'
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Rename user sap_preconfigure variables if found, generic
ansible.builtin.set_fact:
Expand All @@ -38,8 +36,7 @@
sap_general_preconfigure_kernel_parameters: "{{ sap_preconfigure_kernel_parameters | d(sap_general_preconfigure_kernel_parameters) }}"
sap_general_preconfigure_max_hostname_length: "{{ sap_preconfigure_max_hostname_length | d(sap_general_preconfigure_max_hostname_length) }}"
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Rename user sap_preconfigure variables if found, RHEL only
ansible.builtin.set_fact:
Expand All @@ -62,32 +59,28 @@
sap_general_preconfigure_2772999_10: "{{ (sap_preconfigure_2772999_10 | d(sap_general_preconfigure_2772999_10)) | d(false) }}"
when: ansible_facts['distribution'] in ['RedHat']
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Rename sap_preconfigure_db_group_name if defined
ansible.builtin.set_fact:
sap_general_preconfigure_db_group_name: "{{ sap_preconfigure_db_group_name | d(sap_general_preconfigure_db_group_name) }}"
when: sap_preconfigure_db_group_name is defined or sap_general_preconfigure_db_group_name is defined
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Set filename prefix to empty string if role is run in normal mode
ansible.builtin.set_fact:
__sap_general_preconfigure_fact_assert_filename_prefix: ""
when: not sap_general_preconfigure_assert | d(false)
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Prepend filename with assert string if role is run in assert mode
ansible.builtin.set_fact:
__sap_general_preconfigure_fact_assert_filename_prefix: "assert-"
when: sap_general_preconfigure_assert | d(false)
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

# required for installation and configuration tasks:
- name: Gather package facts
Expand All @@ -111,25 +104,23 @@
- name: Gather package facts again after the installation phase
ansible.builtin.package_facts:
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always

- name: Include tasks from 'configuration.yml'
ansible.builtin.include_tasks:
file: '{{ item }}/{{ __sap_general_preconfigure_fact_assert_filename_prefix }}configuration.yml'
apply:
tags: sap_general_preconfigure_configuration_all_steps
tags: sap_general_preconfigure_configuration
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_configuration | d(false)
with_first_found:
- '{{ ansible_distribution.split("_")[0] }}'
- '{{ ansible_distribution }}'
- '{{ ansible_os_family }}.yml'
tags:
- sap_general_preconfigure_configuration
- always

# allow a reboot at the end of the preconfigure role
- name: Flush handlers
ansible.builtin.meta: flush_handlers
tags:
- sap_general_preconfigure_installation
- sap_general_preconfigure_configuration
- always
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/tasks/sapnote/0941735.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
swaptotal_mb = {{ ansible_swaptotal_mb }};
sap_general_preconfigure_size_of_tmpfs_gb = {{ sap_general_preconfigure_size_of_tmpfs_gb }}"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '../RedHat/generic/configure-tmpfs.yml'
ansible.builtin.import_tasks: ../RedHat/generic/configure-tmpfs.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/tasks/sapnote/1391070.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1391070$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1391070$') | first).version }}): Configure uuidd"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '../RedHat/generic/configure-uuidd.yml'
ansible.builtin.import_tasks: ../RedHat/generic/configure-uuidd.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/tasks/sapnote/1771258.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1771258$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1771258$') | first).version }}): User and system resource limits"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '../RedHat/generic/increase-nofile-limits.yml'
ansible.builtin.import_tasks: ../RedHat/generic/increase-nofile-limits.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/tasks/sapnote/2002167.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2002167$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2002167$') | first).version }}): Configure RHEL 7"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '2002167/02-configuration-changes.yml'
ansible.builtin.import_tasks: 2002167/02-configuration-changes.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/tasks/sapnote/2772999.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2772999$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2772999$') | first).version }}): Configure RHEL 8"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '2772999/02-configure-selinux.yml'
ansible.builtin.import_tasks: 2772999/02-configure-selinux.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/tasks/sapnote/3108316.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^3108316$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^3108316$') | first).version }}): Configure RHEL 9"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '3108316/02-configure-selinux.yml'
ansible.builtin.import_tasks: 3108316/02-configure-selinux.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
swaptotal_mb = {{ ansible_swaptotal_mb }};
sap_general_preconfigure_size_of_tmpfs_gb = {{ sap_general_preconfigure_size_of_tmpfs_gb }}"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '../RedHat/generic/assert-tmpfs.yml'
ansible.builtin.import_tasks: ../RedHat/generic/assert-tmpfs.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1391070$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1391070$') | first).version }}): Configure uuidd"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '../RedHat/generic/assert-uuidd.yml'
ansible.builtin.import_tasks: ../RedHat/generic/assert-uuidd.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1771258$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^1771258$') | first).version }}): User and system resource limits"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '../RedHat/generic/assert-nofile-limits.yml'
ansible.builtin.import_tasks: ../RedHat/generic/assert-nofile-limits.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
ansible.builtin.debug:
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2002167$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2002167$') | first).version }}): Configure RHEL 7"
tags:
- always

- name: Import tasks from '2002167/02-assert-configuration-changes.yml'
ansible.builtin.import_tasks: 2002167/02-assert-configuration-changes.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2772999$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2772999$') | first).version }}): Configure RHEL 8"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '2772999/02-assert-selinux.yml'
ansible.builtin.import_tasks: 2772999/02-assert-selinux.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^3108316$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^3108316$') | first).version }}): Configure RHEL 9"
tags:
- sap_general_preconfigure_configuration
- always

- name: Import tasks from '3108316/02-assert-selinux.yml'
ansible.builtin.import_tasks: 3108316/02-assert-selinux.yml
Expand Down

0 comments on commit 7e08d48

Please sign in to comment.