-
Notifications
You must be signed in to change notification settings - Fork 59
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
sap_general_preconfigure: Use tags for limiting the role scope #653
Changes from 5 commits
d0a0743
7194d55
f828b4c
c653640
c2cd1a4
7e08d48
f84f9d3
740ba0b
63bf621
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,19 @@ | |
- name: Display the role path | ||
ansible.builtin.debug: | ||
var: role_path | ||
tags: | ||
- sap_general_preconfigure_installation | ||
- sap_general_preconfigure_configuration | ||
|
||
- 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: | ||
- sap_general_preconfigure_installation | ||
- sap_general_preconfigure_configuration | ||
|
||
- name: Rename user sap_preconfigure variables if found, generic | ||
ansible.builtin.set_fact: | ||
|
@@ -31,6 +37,9 @@ | |
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: | ||
- sap_general_preconfigure_installation | ||
- sap_general_preconfigure_configuration | ||
|
||
- name: Rename user sap_preconfigure variables if found, RHEL only | ||
ansible.builtin.set_fact: | ||
|
@@ -52,45 +61,75 @@ | |
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: | ||
- sap_general_preconfigure_installation | ||
- sap_general_preconfigure_configuration | ||
|
||
- 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 | ||
|
||
- 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 | ||
|
||
- 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 | ||
|
||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already a tag in this task, why adding the same one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code will apply a tag to all tasks of the included file(s). And without the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
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: | ||
- sap_general_preconfigure_installation | ||
- sap_general_preconfigure_configuration | ||
|
||
- 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_all_steps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question done in the line 102 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
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 | ||
|
||
# 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 |
ja9fuchs marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the tag
sap_general_preconfigure_configuration_all_steps
really necessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I tested again and it found no longer a combination of tags which would require both tags. So it seems it's really not required. I'll update the code accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit too fast. Further testing revealed that only with both tags,
sap_general_preconfigure_configuration
andsap_general_preconfigure_configuration_all_steps
, it is possible to execute just one or a few of the configuration steps.With just the tag
sap_general_preconfigure_configuration
, it is possible to run all configuration steps and skip some of them. But I want more. ;-)See also the examples in README.md.