Skip to content

Commit

Permalink
Merge pull request #653 from berndfinger/issue-342
Browse files Browse the repository at this point in the history
sap_general_preconfigure: Use tags for limiting the role scope
  • Loading branch information
berndfinger authored Feb 28, 2024
2 parents 5a790ac + 63bf621 commit 7634e2e
Show file tree
Hide file tree
Showing 62 changed files with 556 additions and 5 deletions.
52 changes: 52 additions & 0 deletions roles/sap_general_preconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,58 @@ sap_general_preconfigure_db_group_name: dba

<!-- END: Role Input Parameters for sap_general_preconfigure -->

## Tags (RHEL systems only)

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_3108316`: Perform only the tasks(s) related to this SAP note.
- tag `sap_general_preconfigure_2772999_03`: Perform only the tasks(s) related to step 3 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 (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.yml
```

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

Sample call for only performing all configuration tasks:
```
# ansible-playbook sap.yml --tags=sap_general_preconfigure_configuration
```

Sample call for only verifying and modifying the /etc/hosts file:
```
# 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.yml --tags=sap_general_preconfigure_configuration --skip_tags=sap_general_preconfigure_etc_hosts
```

Sample call for only performing the configuration activities related to SAP note 3108316 (RHEL 9 specific):
```
# ansible-playbook sap.yml --tags=sap_general_preconfigure_3108316
```

Sample call for performing all configuration activities except those related to step 2 (SELinux settings) of SAP note 3108316 (RHEL 9 specific):
Sample call for only performing the configuration activities related to step 2 (SELinux settings) of SAP note 3108316 (RHEL 9 specific):
```
# ansible-playbook sap.yml --tags=sap_general_preconfigure_3108316_02
```

Sample call for performing all configuration activities 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 --skip_tags=sap_general_preconfigure_3108316_02
```

## Dependencies

This role does not depend on any other role.
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
20 changes: 19 additions & 1 deletion 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,9 +43,17 @@
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: "sapnote/{{ sap_note_line_item.number }}.yml"
ansible.builtin.include_tasks:
file: "sapnote/{{ sap_note_line_item.number }}.yml"
with_items: "{{ __sap_general_preconfigure_sapnotes_versions | difference(['']) }}"
loop_control:
loop_var: sap_note_line_item
tags:
- always
34 changes: 32 additions & 2 deletions roles/sap_general_preconfigure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
- name: Display the role path
ansible.builtin.debug:
var: role_path
tags:
- always

- name: Include OS specific vars, specific
ansible.builtin.include_vars: '{{ item }}'
with_first_found:
- '{{ ansible_distribution.split("_")[0] }}_{{ ansible_distribution_version }}.yml'
- '{{ ansible_distribution.split("_")[0] }}_{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_os_family }}.yml'
tags:
- always

- name: Rename user sap_preconfigure variables if found, generic
ansible.builtin.set_fact:
Expand All @@ -31,6 +35,8 @@
sap_general_preconfigure_modify_etc_hosts: "{{ sap_preconfigure_modify_etc_hosts | d(sap_general_preconfigure_modify_etc_hosts) }}"
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:
- always

- name: Rename user sap_preconfigure variables if found, RHEL only
ansible.builtin.set_fact:
Expand All @@ -52,45 +58,69 @@
sap_general_preconfigure_2772999_09: "{{ (sap_preconfigure_2772999_09 | d(sap_general_preconfigure_2772999_09)) | d(false) }}"
sap_general_preconfigure_2772999_10: "{{ (sap_preconfigure_2772999_10 | d(sap_general_preconfigure_2772999_10)) | d(false) }}"
when: ansible_facts['distribution'] in ['RedHat']
tags:
- 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:
- 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:
- 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:
- always

# required for installation and configuration tasks:
- name: Gather package facts
ansible.builtin.package_facts:
tags:
- sap_general_preconfigure_installation

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

- name: Gather package facts again after the installation phase
ansible.builtin.package_facts:
tags:
- always

- name: Include tasks from 'configuration.yml'
ansible.builtin.include_tasks: '{{ item }}/{{ __sap_general_preconfigure_fact_assert_filename_prefix }}configuration.yml'
ansible.builtin.include_tasks:
file: '{{ item }}/{{ __sap_general_preconfigure_fact_assert_filename_prefix }}configuration.yml'
apply:
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:
- always

# allow a reboot at the end of the preconfigure role
- name: Flush handlers
ansible.builtin.meta: flush_handlers
tags:
- always
5 changes: 5 additions & 0 deletions roles/sap_general_preconfigure/tasks/sapnote/0941735.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
memtotal_mb = {{ ansible_memtotal_mb }};
swaptotal_mb = {{ ansible_swaptotal_mb }};
sap_general_preconfigure_size_of_tmpfs_gb = {{ sap_general_preconfigure_size_of_tmpfs_gb }}"
tags:
- always

- name: Import tasks from '../RedHat/generic/configure-tmpfs.yml'
ansible.builtin.import_tasks: ../RedHat/generic/configure-tmpfs.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_0941735 | d(false)
tags:
- sap_general_preconfigure_0941735
- sap_general_preconfigure_configure_tmpfs
5 changes: 5 additions & 0 deletions roles/sap_general_preconfigure/tasks/sapnote/1391070.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
ansible.builtin.debug:
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:
- always

- name: Import tasks from '../RedHat/generic/configure-uuidd.yml'
ansible.builtin.import_tasks: ../RedHat/generic/configure-uuidd.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_1391070 | d(false)
tags:
- sap_general_preconfigure_1391070
- sap_general_preconfigure_configure_uuidd
5 changes: 5 additions & 0 deletions roles/sap_general_preconfigure/tasks/sapnote/1771258.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
ansible.builtin.debug:
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:
- always

- name: Import tasks from '../RedHat/generic/increase-nofile-limits.yml'
ansible.builtin.import_tasks: ../RedHat/generic/increase-nofile-limits.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_1771258 | d(false)
tags:
- sap_general_preconfigure_1771258
- sap_general_preconfigure_nofile_limits
17 changes: 17 additions & 0 deletions roles/sap_general_preconfigure/tasks/sapnote/2002167.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,40 @@
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-configuration-changes.yml'
ansible.builtin.import_tasks: 2002167/02-configuration-changes.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_2002167_02 | d(false)
tags:
- sap_general_preconfigure_2002167
- sap_general_preconfigure_2002167_02

- name: Import tasks from '2002167/03-setting-the-hostname.yml'
ansible.builtin.import_tasks: 2002167/03-setting-the-hostname.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_2002167_03 | d(false)
tags:
- sap_general_preconfigure_2002167
- sap_general_preconfigure_2002167_03

- name: Import tasks from '2002167/04-linux-kernel-parameters.yml'
ansible.builtin.import_tasks: 2002167/04-linux-kernel-parameters.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_2002167_04 | d(false)
tags:
- sap_general_preconfigure_2002167
- sap_general_preconfigure_2002167_04

- name: Import tasks from '2002167/05-process-resource-limits.yml'
ansible.builtin.import_tasks: 2002167/05-process-resource-limits.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_2002167_05 | d(false)
tags:
- sap_general_preconfigure_2002167
- sap_general_preconfigure_2002167_05

- name: Import tasks from '2002167/06-additional-notes-for-installing-sap-systems.yml'
ansible.builtin.import_tasks: 2002167/06-additional-notes-for-installing-sap-systems.yml
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_2002167_06 | d(false)
tags:
- sap_general_preconfigure_2002167
- sap_general_preconfigure_2002167_06
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
- name: Assert 2002167-2a
ansible.builtin.debug:
msg: "SAP note 2002167 Step 2a: Configure the Firewall"
tags:
- sap_general_preconfigure_firewall

- name: Import tasks from '../../RedHat/generic/assert-firewall.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/assert-firewall.yml
tags:
- sap_general_preconfigure_firewall

- name: Assert 2002167-2b
ansible.builtin.debug:
msg: "SAP note 2002167 Step 2b: Configure SELinux"
tags:
- sap_general_preconfigure_selinux

- name: Import tasks from '../../RedHat/generic/assert-selinux.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/assert-selinux.yml
tags:
- sap_general_preconfigure_selinux
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
- name: Configure 2002167-2a
ansible.builtin.debug:
msg: "SAP note 2002167 Step 2a: Configure the Firewall"
tags:
- sap_general_preconfigure_firewall
- sap_general_preconfigure_selinux

- name: Import tasks from '../../RedHat/generic/configure-firewall.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/configure-firewall.yml
tags:
- sap_general_preconfigure_firewall

- name: Configure 2002167-2b
ansible.builtin.debug:
msg: "SAP note 2002167 Step 2b: Configure SELinux"

- name: Import tasks from '../../RedHat/generic/configure-selinux.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/configure-selinux.yml
tags:
- sap_general_preconfigure_selinux
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
- name: Assert 2002167-3
ansible.builtin.debug:
msg: "SAP note 2002167 Step 3: Setting the Hostname"
tags:
- sap_general_preconfigure_hostname
- sap_general_preconfigure_etc_hosts
- sap_general_preconfigure_dns_name_resolution

- name: Import tasks from '../../RedHat/generic/assert-hostname.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/assert-hostname.yml
tags:
- sap_general_preconfigure_hostname

- name: Import tasks from '../../RedHat/generic/assert-etc-hosts.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/assert-etc-hosts.yml
tags:
- sap_general_preconfigure_etc_hosts

- name: Import tasks from '../../RedHat/generic/assert-dns-name-resolution.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/assert-dns-name-resolution.yml
tags:
- sap_general_preconfigure_dns_name_resolution
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
- name: Configure 2002167-3
ansible.builtin.debug:
msg: "SAP note 2002167 Step 3: Setting the Hostname"
tags:
- sap_general_preconfigure_hostname
- sap_general_preconfigure_etc_hosts
- sap_general_preconfigure_dns_name_resolution

- name: Import tasks from '../../RedHat/generic/configure-hostname.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/configure-hostname.yml
tags:
- sap_general_preconfigure_hostname

- name: Import tasks from '../../RedHat/generic/configure-etc-hosts.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/configure-etc-hosts.yml
tags:
- sap_general_preconfigure_etc_hosts

- name: Import tasks from '../../RedHat/generic/check-dns-name-resolution.yml'
ansible.builtin.import_tasks: ../../RedHat/generic/check-dns-name-resolution.yml
tags:
- sap_general_preconfigure_dns_name_resolution
Loading

0 comments on commit 7634e2e

Please sign in to comment.