From 38666ba6168ad1824e0227864506b04d9a8cda2b Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 17 Jun 2024 16:42:28 +0200 Subject: [PATCH 01/24] Initial commit for new playbooks --- playbooks/disclaimer.yml | 20 +++++ playbooks/sap_hana_install.yml | 122 ++++++++++++++++++++++++++++ playbooks/sap_hana_preconfigure.yml | 88 ++++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 playbooks/disclaimer.yml create mode 100644 playbooks/sap_hana_install.yml create mode 100644 playbooks/sap_hana_preconfigure.yml diff --git a/playbooks/disclaimer.yml b/playbooks/disclaimer.yml new file mode 100644 index 000000000..079129e90 --- /dev/null +++ b/playbooks/disclaimer.yml @@ -0,0 +1,20 @@ +--- +- name: Disclaimer for using playbooks + hosts: localhost + gather_facts: false + + tasks: + - name: Disclaimer + ansible.builtin.debug: + msg: |- + ********************************************************************************************************************* + The playbooks of this collections can be used interactively to reach a defined state. + Instead of answering questions interactively, you can pass a variable file + with the required values. + To turn off this diclaimer set sap_playbook_disclaimer to false. + This playbook runs against localhost only. + If you want to use the playbook against multiple hosts, create an inventory containing + these hosts and run the playbook with the options `-i inventory -e target_group=all` + where `inventory` is the filename of the inventory and `all` is the group the playbook is excuted against. + For details creating an inventory see: https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html + ********************************************************************************************************************* diff --git a/playbooks/sap_hana_install.yml b/playbooks/sap_hana_install.yml new file mode 100644 index 000000000..46fd63043 --- /dev/null +++ b/playbooks/sap_hana_install.yml @@ -0,0 +1,122 @@ +--- +## +# Call this playbook interactively with +# ansible-playbook community.sap_install.sap_hana_preconfigure +# +# or alternatively unattended with +# ansible-playbook community.sap_install.sap_hana_preconfigure -e @myvars.yml +# +# The file myvars. yaml needs to contain the following variables +# +- name: Disclaimer + ansible.builtin.import_playbook: disclaimer.yml # TODO: check if FQDN is required/optional + when: sap_playbook_disclaimer | d('true') + +- name: Collecting Variables + hosts: localhost + + vars_prompt: + - name: "sap_domain" + prompt: "Enter Domainname of your SAP systems (leave empty for using system default: " + private: false + default: "{{ sap_domain | d('') }}" + + - name: "sap_update_hosts" + prompt: "Do you want the system to update /etc/hosts for SAP (y/n)" + private: false + default: "y" + + - name: "sap_update" + prompt: "Do you want to update the system? (y/n)" + private: false + default: "n" + + - name: "sap_fail_if_reboot_required" + prompt: "Do you want to stop with an error if the system needs a reboot? (y/n)" + private: false + default: "n" + + - name: "sap_reboot" + prompt: "Do you want to reboot the system if required? (y/n)" + private: false + default: "n" + + - name: "sap_path" + prompt: "Enter path to SAP HANA install files" + private: false + default: /sap-install + + - name: "sap_hana_sid" + prompt: "SAP HANA SID" + private: false + default: "HDB" + + - name: "sap_hana_instance_number" + prompt: "SAP HANA instance number" + private: false + default: "90" + + - name: "sap_pass" + prompt: "SAP HANA password" + private: true + unsafe: true + + tasks: + - name: Configure Role Variables + ansible.builtin.set_fact: + sap_domain: '{{ sap_domain }}' + ### redhat.sap_install.sap_general_preconfigure + sap_general_preconfigure_modify_etc_hosts: '{{ (sap_update_hosts == "y") | ternary(true, false) }}' + sap_general_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' + sap_general_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' + # sap_general_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' + ### redhat.sap_install.sap_hana_preconfigure + sap_hana_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' + sap_hana_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' + sap_hana_preconfigure_reboot_ok: '{{ (sap_reboot == "n") | ternary(false, true) }}' + # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' + ## BEGIN sap_hana_install parameters + sap_hana_install_software_directory: '{{ sap_path }}' + sap_hana_install_software_extract_directory: /tmp/sap-hana-inst + sap_hana_install_master_password: '{{ sap_pass }}' + sap_hana_sid: '{{ sap_hana_sid }}' + sap_hana_instance_number: '{{ sap_hana_instance_number }}' + # sap_hana_install_restrict_max_mem: 'y' + # sap_hana_install_max_mem: 38912 + # sap_hana_install_system_roles_collection: 'redhat.rhel_system_roles' +## END sap_hana_install parameters + +- name: Prepare system for SAP HANA Installation + hosts: "{{ target_group | d('localhost') }}" + become: true + + tasks: + - name: Ansible Role Configuration + ansible.builtin.debug: + msg: |- + The Hana setup runs with the following configuration + - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' + - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' + - 'Domain : {{ (sap_domain | length > 0) | ternary(sap_domain, ansible_domain) }}' + - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts }}' + - 'Update OS : {{ sap_hana_preconfigure_update }}' + - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok }}' + - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required }}' + - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' + + - name: Pause playbook execution to verify parameters + when: sap_playbook_disclaimer | d('true') + ansible.builtin.pause: + prompt: Press enter to continue + + - name: Prepare general preconfiguration + ansible.builtin.include_role: + name: community.sap_install.sap_general_preconfigure + + - name: Prepare system for HANA installation + ansible.builtin.include_role: + name: community.sap_install.sap_hana_preconfigure + + - name: Install SAP HANA + ansible.builtin.include_role: + name: community.sap_install.sap_hana_install diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml new file mode 100644 index 000000000..afe976d30 --- /dev/null +++ b/playbooks/sap_hana_preconfigure.yml @@ -0,0 +1,88 @@ +--- +## +# Call this playbook interactively with +# ansible-playbook community.sap_install.sap_hana_preconfigure +# +# or alternatively unattended with +# ansible-playbook community.sap_install.sap_hana_preconfigure -e @myvars.yml +# +# The file myvars. yaml needs to contain the following variables +# +- name: Disclaimer + ansible.builtin.import_playbook: disclaimer.yml # TODO: check if FQDN is required/optional + when: sap_playbook_disclaimer | d('true') + +- name: Collecting Variables + hosts: localhost + + vars_prompt: + - name: "sap_domain" + prompt: "Enter Domainname of your SAP systems (leave empty for using system default: " + private: false + default: "{{ sap_domain | d('') }}" + + - name: "sap_update_hosts" + prompt: "Do you want the system to update /etc/hosts for SAP (y/n)" + private: false + default: "y" + + - name: "sap_update" + prompt: "Do you want to update the system? (y/n)" + private: false + default: "n" + + - name: "sap_fail_if_reboot_required" + prompt: "Do you want to stop with an error if the system needs a reboot? (y/n)" + private: false + default: "n" + + - name: "sap_reboot" + prompt: "Do you want to reboot the system if required? (y/n)" + private: false + default: "n" + + tasks: + - name: Configure Role Variables + ansible.builtin.set_fact: + sap_domain: '{{ sap_domain }}' + ### redhat.sap_install.sap_general_preconfigure + sap_general_preconfigure_modify_etc_hosts: '{{ (sap_update_hosts == "y") | ternary(true, false) }}' + sap_general_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' + sap_general_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' + # sap_general_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' + ### redhat.sap_install.sap_hana_preconfigure + sap_hana_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' + sap_hana_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' + sap_hana_preconfigure_reboot_ok: '{{ (sap_reboot == "n") | ternary(false, true) }}' + # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' + +- name: Prepare system for SAP HANA Installation + hosts: "{{ target_group | d('localhost') }}" + become: true + + tasks: + - name: Ansible Role Configuration + ansible.builtin.debug: + msg: |- + The Hana setup runs with the following configuration + - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' + - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' + - 'Domain : {{ (sap_domain | length > 0) | ternary(sap_domain, ansible_domain) }}' + - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts }}' + - 'Update OS : {{ sap_hana_preconfigure_update }}' + - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok }}' + - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required }}' + - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' + + - name: Pause playbook execution to verify parameters + when: sap_playbook_disclaimer | d('true') + ansible.builtin.pause: + prompt: Press enter to continue + + - name: Prepare general preconfiguration + ansible.builtin.include_role: + name: community.sap_install.sap_general_preconfigure + + - name: Prepare system for HANA installation + ansible.builtin.include_role: + name: community.sap_install.sap_hana_preconfigure From 3416f296f935e2a553459c5b906f081aa33363c1 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 21 Jun 2024 11:35:30 +0200 Subject: [PATCH 02/24] new interactive playbook and non interactive playbook --- playbooks/disclaimer.yml | 20 ------- playbooks/sap_hana_preconfigure.yml | 67 ++++++++++++------------ playbooks/sap_hana_preconfigure_exec.yml | 53 +++++++++++++++++++ 3 files changed, 87 insertions(+), 53 deletions(-) delete mode 100644 playbooks/disclaimer.yml create mode 100644 playbooks/sap_hana_preconfigure_exec.yml diff --git a/playbooks/disclaimer.yml b/playbooks/disclaimer.yml deleted file mode 100644 index 079129e90..000000000 --- a/playbooks/disclaimer.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: Disclaimer for using playbooks - hosts: localhost - gather_facts: false - - tasks: - - name: Disclaimer - ansible.builtin.debug: - msg: |- - ********************************************************************************************************************* - The playbooks of this collections can be used interactively to reach a defined state. - Instead of answering questions interactively, you can pass a variable file - with the required values. - To turn off this diclaimer set sap_playbook_disclaimer to false. - This playbook runs against localhost only. - If you want to use the playbook against multiple hosts, create an inventory containing - these hosts and run the playbook with the options `-i inventory -e target_group=all` - where `inventory` is the filename of the inventory and `all` is the group the playbook is excuted against. - For details creating an inventory see: https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html - ********************************************************************************************************************* diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index afe976d30..6dec8cb89 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -8,16 +8,32 @@ # # The file myvars. yaml needs to contain the following variables # -- name: Disclaimer - ansible.builtin.import_playbook: disclaimer.yml # TODO: check if FQDN is required/optional - when: sap_playbook_disclaimer | d('true') +- name: Playbook Usage + hosts: localhost + tasks: + - name: Playbook Usage + ansible.builtin.debug: + msg: |- + ***************************************************************************** + * sap_hana_preconfigure * + * * + * This playbook is used to prepare an SAP HANA system. * + * The minimum viable parameters to succussfully prepare your system for an * + * SAP HANA installation will be asked. * + * Useful defaults will be set, so that it is save to just press enter * + ***************************************************************************** - name: Collecting Variables hosts: localhost vars_prompt: + - name: "sap_systems" + prompt: "Enter comma separated list of systems, you want to prepare for SAP HANA" + private: false + default: "localhost" + - name: "sap_domain" - prompt: "Enter Domainname of your SAP systems (leave empty for using system default: " + prompt: "Enter DNS Domainname of your SAP systems (leave empty for using system default: " private: false default: "{{ sap_domain | d('') }}" @@ -42,6 +58,13 @@ default: "n" tasks: + - name: Prepare inventory + when: sap_systems != 'localhost' + ansible.builtin.add_host: + groups: sap_hana_prepare_hosts + name: '{{ item }}' + loop: '{{ sap_systems | split(",") | list }}' + - name: Configure Role Variables ansible.builtin.set_fact: sap_domain: '{{ sap_domain }}' @@ -56,33 +79,11 @@ sap_hana_preconfigure_reboot_ok: '{{ (sap_reboot == "n") | ternary(false, true) }}' # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' -- name: Prepare system for SAP HANA Installation - hosts: "{{ target_group | d('localhost') }}" - become: true - - tasks: - - name: Ansible Role Configuration - ansible.builtin.debug: - msg: |- - The Hana setup runs with the following configuration - - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' - - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' - - 'Domain : {{ (sap_domain | length > 0) | ternary(sap_domain, ansible_domain) }}' - - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts }}' - - 'Update OS : {{ sap_hana_preconfigure_update }}' - - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok }}' - - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required }}' - - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' - - - name: Pause playbook execution to verify parameters - when: sap_playbook_disclaimer | d('true') - ansible.builtin.pause: - prompt: Press enter to continue - - - name: Prepare general preconfiguration - ansible.builtin.include_role: - name: community.sap_install.sap_general_preconfigure +- name: Run sap_hana_prepare_exec playbook + ansible.builtin.import_playbook: sap_hana_preconfigure_exec.yml + vars: + sap_playbook_paramter_confirm: true + #sap_hana_group: 'sap_hana_prepare_hosts' + sap_domain: "{{ hostvars['localhost']['sap_domain'] }}" + sap_general_preconfigure_modify_etc_hosts: "{{ hostvars['localhost']['sap_general_preconfigure_modify_etc_hosts'] }}" - - name: Prepare system for HANA installation - ansible.builtin.include_role: - name: community.sap_install.sap_hana_preconfigure diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml new file mode 100644 index 000000000..a2069d487 --- /dev/null +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -0,0 +1,53 @@ +--- +## +# Call this playbook only with all variables defined. +# The minimum viable set of variables which need to be defined are: +# +# sap_hana_group: name of group in inventory - defaults to localhost if not set +# sap_domain: SAP domain - defaults to ansible_domain if not set, but must not be empty +# +# for redhat.sap_install.sap_general_preconfigure +# sap_general_preconfigure_modify_etc_hosts: defaults to true +# sap_general_preconfigure_update: defaults to false +# sap_general_preconfigure_fail_if_reboot_required: defaults to true +# +# for redhat.sap_install.sap_hana_preconfigure +# sap_hana_preconfigure_update: defaults to false +# sap_hana_preconfigure_fail_if_reboot_required: defaults to true +# sap_hana_preconfigure_reboot_ok: defaults to false + +- name: Prepare system for SAP HANA Installation + hosts: "{{ sap_hana_group | d('localhost') }}" + become: true + tasks: + - name: Ansible Role Configuration + ansible.builtin.debug: + + ### ACHTUNG VArs nur bei Localhost gesetzt, daher Zugriff via hostvars[localhost] + ### Wunsch Target_group wird automatisch aus -i gesetzt, falls nicht explizit angegeben. + + # sap_swpm_extract_directory testen !!! + + msg: |- + The Hana setup runs with the following configuration + - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' + - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' + - 'Domain : {{ (sap_domain | length > 0) | ternary(sap_domain, ansible_domain) }}' + - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts }}' + - 'Update OS : {{ sap_hana_preconfigure_update }}' + - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok }}' + - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required }}' + - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' + + - name: Pause playbook execution to verify parameters + when: sap_playbook_paramter_confirm | d('false') + ansible.builtin.pause: + prompt: Press enter to continue + + - name: Prepare general preconfiguration + ansible.builtin.include_role: + name: community.sap_install.sap_general_preconfigure + + - name: Prepare system for HANA installation + ansible.builtin.include_role: + name: community.sap_install.sap_hana_preconfigure From b4c882844a9e936fd8ac13610dc59258ce9ba272 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 21 Jun 2024 12:24:15 +0200 Subject: [PATCH 03/24] Interactive Playbooks --- playbooks/README.md | 56 +++++++++++++++++++++--- playbooks/sap_hana_preconfigure.yml | 10 +++-- playbooks/sap_hana_preconfigure_exec.yml | 2 +- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 7362b9535..a46e52839 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -1,8 +1,52 @@ -# List of playbooks +# Ansible Collection Playbooks -- prepare-for-hana -- prepare-for-netweaver -- install-sap-hana -- install-sap-hana-cluster -- install-sap-hana-s4 +The playbooks in this directory can be used as templates for your own playbooks +(starting with sample-) and some can be called directly with interactive variable collection +or included in your own playbooks or workflows. + +## Usage of playbooks + +### sap-hana-prepare.yml + +This playbook collects information for preparing an SAP system for an SAP HANA installation. + +```[bash] +ansible-playbook community.sap_install.sap_hana_preconfigure.yml +``` + +When you call this playbook against a remote host make sure the user can connect and assume root without a password or pass the following parameters if necessary + +```[bash] + -u : User that establishes the ssh connection + -k: asks for password or passphrase of the connection user, if required for ssh + -K: asks for the privilige escalation password of the connection user to become root on the target host +``` + +If you want to embed this playbook or run non-interactive, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). + +```[yaml] +[my_hanas] +hana1 +hana2 +``` + +Prepare a variable config file with the following parameters (adapt to your needs): + +```[yaml] + # sap_playbook_parameter_confirm: false + sap_hana_group: 'my_hanas' + sap_domain: my.sap.domain + sap_general_preconfigure_modify_etc_hosts: true + sap_general_preconfigure_update: true + sap_general_preconfigure_fail_if_reboot_required: false + sap_hana_preconfigure_update: true + sap_hana_preconfigure_fail_if_reboot_required: false + sap_hana_preconfigure_reboot_ok: true +``` + +Now you can run the playbook with + +```[bash] +ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i inventory -e @my_vars.yml +``` diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 6dec8cb89..ddc2c8f7a 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -82,8 +82,12 @@ - name: Run sap_hana_prepare_exec playbook ansible.builtin.import_playbook: sap_hana_preconfigure_exec.yml vars: - sap_playbook_paramter_confirm: true - #sap_hana_group: 'sap_hana_prepare_hosts' + sap_playbook_parameter_confirm: true + sap_hana_group: "{{ ( groups['sap_hana_prepare_hosts'] is defined) | ternary ('sap_hana_prepare_hosts','localhost') }}" sap_domain: "{{ hostvars['localhost']['sap_domain'] }}" sap_general_preconfigure_modify_etc_hosts: "{{ hostvars['localhost']['sap_general_preconfigure_modify_etc_hosts'] }}" - + sap_general_preconfigure_update: "{{ hostvars['localhost']['sap_general_preconfigure_update'] }}" + sap_general_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_general_preconfigure_fail_if_reboot_required'] }}" + sap_hana_preconfigure_update: "{{ hostvars['localhost']['sap_hana_preconfigure_update'] }}" + sap_hana_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_hana_preconfigure_fail_if_reboot_required'] }}" + sap_hana_preconfigure_reboot_ok: "{{ hostvars['localhost']['sap_hana_preconfigure_reboot_ok'] }}" diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index a2069d487..2017500ac 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -40,7 +40,7 @@ - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' - name: Pause playbook execution to verify parameters - when: sap_playbook_paramter_confirm | d('false') + when: sap_playbook_parameter_confirm | d('false') ansible.builtin.pause: prompt: Press enter to continue From 7e4806720ada64d64db0c320dbd6b6f228ed3045 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 21 Jun 2024 12:35:30 +0200 Subject: [PATCH 04/24] Updates to README --- playbooks/README.md | 9 +++++++-- playbooks/sap_hana_preconfigure_exec.yml | 4 ---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index a46e52839..8a47da0cc 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -10,6 +10,7 @@ or included in your own playbooks or workflows. ### sap-hana-prepare.yml This playbook collects information for preparing an SAP system for an SAP HANA installation. +Run the following command: ```[bash] ansible-playbook community.sap_install.sap_hana_preconfigure.yml @@ -25,6 +26,8 @@ When you call this playbook against a remote host make sure the user can connect If you want to embed this playbook or run non-interactive, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). +Create the file `my_inventory` with the following content: + ```[yaml] [my_hanas] hana1 @@ -33,6 +36,8 @@ hana2 Prepare a variable config file with the following parameters (adapt to your needs): +Create a parameter file `my_vars` with the following content: + ```[yaml] # sap_playbook_parameter_confirm: false sap_hana_group: 'my_hanas' @@ -45,8 +50,8 @@ Prepare a variable config file with the following parameters (adapt to your need sap_hana_preconfigure_reboot_ok: true ``` -Now you can run the playbook with +Now you can run the playbook non-interactively with ```[bash] -ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i inventory -e @my_vars.yml +ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i my_inventory -e @my_vars.yml ``` diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index 2017500ac..7aba5d088 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -22,10 +22,6 @@ tasks: - name: Ansible Role Configuration ansible.builtin.debug: - - ### ACHTUNG VArs nur bei Localhost gesetzt, daher Zugriff via hostvars[localhost] - ### Wunsch Target_group wird automatisch aus -i gesetzt, falls nicht explizit angegeben. - # sap_swpm_extract_directory testen !!! msg: |- From 0129e52e75e23abbb772297fd151d8fc025219a2 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 21 Jun 2024 12:37:34 +0200 Subject: [PATCH 05/24] Update im Readme --- playbooks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/README.md b/playbooks/README.md index 8a47da0cc..4da773d28 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -7,7 +7,7 @@ or included in your own playbooks or workflows. ## Usage of playbooks -### sap-hana-prepare.yml +### Prepare System for SAP HANA installation (sap_hana_prepare.yml/sap_hana_prepare_exec.yml) This playbook collects information for preparing an SAP system for an SAP HANA installation. Run the following command: From 4145c1020ea3db4be43e15df4cb5b9f637a2f06c Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 21 Jun 2024 12:38:52 +0200 Subject: [PATCH 06/24] update to Readme --- playbooks/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 4da773d28..234655068 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -26,7 +26,7 @@ When you call this playbook against a remote host make sure the user can connect If you want to embed this playbook or run non-interactive, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). -Create the file `my_inventory` with the following content: +Create the file `my_inventory` similar to: ```[yaml] [my_hanas] @@ -36,7 +36,7 @@ hana2 Prepare a variable config file with the following parameters (adapt to your needs): -Create a parameter file `my_vars` with the following content: +Create a parameter file `my_vars` with similar content: ```[yaml] # sap_playbook_parameter_confirm: false From 98472927ba3c5d14934f77226578459bd9bce558 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 1 Jul 2024 15:18:19 +0200 Subject: [PATCH 07/24] Playbooks: Update according to Bernd feedback --- playbooks/README.md | 1 + playbooks/sap_hana_preconfigure.yml | 2 +- playbooks/sap_hana_preconfigure_exec.yml | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 234655068..232208478 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -55,3 +55,4 @@ Now you can run the playbook non-interactively with ```[bash] ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i my_inventory -e @my_vars.yml ``` +NOTE: If you do not define the parameter `sap_hana_group` the playbook will run against all hosts in the inventory unless limited with `-l hostname' or localhost if no inventory is defined. \ No newline at end of file diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index ddc2c8f7a..4e0bba98b 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -30,7 +30,7 @@ - name: "sap_systems" prompt: "Enter comma separated list of systems, you want to prepare for SAP HANA" private: false - default: "localhost" + default: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" - name: "sap_domain" prompt: "Enter DNS Domainname of your SAP systems (leave empty for using system default: " diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index 7aba5d088..bb51c506e 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -17,11 +17,12 @@ # sap_hana_preconfigure_reboot_ok: defaults to false - name: Prepare system for SAP HANA Installation - hosts: "{{ sap_hana_group | d('localhost') }}" + hosts: "{{ sap_hana_group | d((groups['all'] == []) | ternary ('localhost', groups['all'] | join(','))) }}" become: true tasks: - name: Ansible Role Configuration ansible.builtin.debug: + # sap_swpm_extract_directory testen !!! msg: |- From 822ecdec84174593e6df54b511ad22597554eb0a Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 1 Jul 2024 15:41:36 +0200 Subject: [PATCH 08/24] playbooks: little simplification and README update --- playbooks/README.md | 7 +++++-- playbooks/sap_hana_preconfigure_exec.yml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 232208478..542ff16fd 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -16,6 +16,9 @@ Run the following command: ansible-playbook community.sap_install.sap_hana_preconfigure.yml ``` +This playbook runs against localhost and/or remote hosts. +Remote hosts can be defined in an inventory in a file, or with -i on the commandline e.g. `-i inventoryfile` or `-i host1,host2,host3,` and execution can be of course limited with -l. +Nonetheless you need to confirm the hosts in the interactive dialog. When you call this playbook against a remote host make sure the user can connect and assume root without a password or pass the following parameters if necessary ```[bash] @@ -24,7 +27,7 @@ When you call this playbook against a remote host make sure the user can connect -K: asks for the privilige escalation password of the connection user to become root on the target host ``` -If you want to embed this playbook or run non-interactive, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). +If you want to embed this playbook or run a non-interactive version, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). Create the file `my_inventory` similar to: @@ -35,7 +38,6 @@ hana2 ``` Prepare a variable config file with the following parameters (adapt to your needs): - Create a parameter file `my_vars` with similar content: ```[yaml] @@ -55,4 +57,5 @@ Now you can run the playbook non-interactively with ```[bash] ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i my_inventory -e @my_vars.yml ``` + NOTE: If you do not define the parameter `sap_hana_group` the playbook will run against all hosts in the inventory unless limited with `-l hostname' or localhost if no inventory is defined. \ No newline at end of file diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index bb51c506e..fb5996566 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -17,7 +17,7 @@ # sap_hana_preconfigure_reboot_ok: defaults to false - name: Prepare system for SAP HANA Installation - hosts: "{{ sap_hana_group | d((groups['all'] == []) | ternary ('localhost', groups['all'] | join(','))) }}" + hosts: "{{ sap_hana_group | d((groups['all'] == []) | ternary ('localhost', 'all')) }}" become: true tasks: - name: Ansible Role Configuration From 2f668b0c4fb9c9a532f7f2d4021a2849d9cae105 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 1 Jul 2024 15:45:16 +0200 Subject: [PATCH 09/24] playbook sap_hana_preconfigure.yml usage update --- playbooks/sap_hana_preconfigure.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 4e0bba98b..9f28d7599 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -21,6 +21,10 @@ * The minimum viable parameters to succussfully prepare your system for an * * SAP HANA installation will be asked. * * Useful defaults will be set, so that it is save to just press enter * + * * + * If you want to run these steps unattended, please use the playbook * + * sap_hana_preconfigure_exec.yml instead with a properly prepared variable * + * file. (See README for more details) * ***************************************************************************** - name: Collecting Variables From 4449730b38248fa0341e34d389e69f5ea4f8641d Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Wed, 3 Jul 2024 10:22:50 +0200 Subject: [PATCH 10/24] sap_playbooks: feedback incorporated --- playbooks/sap_hana_preconfigure_exec.yml | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index fb5996566..68cf4500f 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -1,6 +1,7 @@ --- ## # Call this playbook only with all variables defined. +# # The minimum viable set of variables which need to be defined are: # # sap_hana_group: name of group in inventory - defaults to localhost if not set @@ -15,6 +16,10 @@ # sap_hana_preconfigure_update: defaults to false # sap_hana_preconfigure_fail_if_reboot_required: defaults to true # sap_hana_preconfigure_reboot_ok: defaults to false +# +# Please note: if the variable sap_playbook_parameter_confirm is set to true, the playbook +# stops execution and waits for an input. If you want to run the playbook in +# non-interactive mode, leave the variable unset or set to false. - name: Prepare system for SAP HANA Installation hosts: "{{ sap_hana_group | d((groups['all'] == []) | ternary ('localhost', 'all')) }}" @@ -22,29 +27,25 @@ tasks: - name: Ansible Role Configuration ansible.builtin.debug: - - # sap_swpm_extract_directory testen !!! - msg: |- The Hana setup runs with the following configuration - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' - - 'Domain : {{ (sap_domain | length > 0) | ternary(sap_domain, ansible_domain) }}' - - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts }}' - - 'Update OS : {{ sap_hana_preconfigure_update }}' - - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok }}' - - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required }}' - - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' + - 'Domain : {{ (sap_domain | d('') | length > 0) | ternary(sap_domain, ansible_domain) }}' + - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts | d('false') }}' + - 'Update OS : {{ sap_hana_preconfigure_update | d('false') }}' + - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok | d('false') }}' + - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required | d('true') }}' - - name: Pause playbook execution to verify parameters + - name: Pause Playbook to verify parameters when: sap_playbook_parameter_confirm | d('false') ansible.builtin.pause: prompt: Press enter to continue - - name: Prepare general preconfiguration + - name: Perform the general SAP configuration ansible.builtin.include_role: name: community.sap_install.sap_general_preconfigure - - name: Prepare system for HANA installation + - name: Perform the SAP HANA specific configuration ansible.builtin.include_role: name: community.sap_install.sap_hana_preconfigure From 7f46b7bbb5cec80ba1c145760af5921ac9ff47b4 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 8 Jul 2024 12:51:00 +0200 Subject: [PATCH 11/24] corrected when statement --- playbooks/sap_hana_preconfigure_exec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index 68cf4500f..9842e12c4 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -38,7 +38,7 @@ - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required | d('true') }}' - name: Pause Playbook to verify parameters - when: sap_playbook_parameter_confirm | d('false') + when: sap_playbook_parameter_confirm | d('false') | bool ansible.builtin.pause: prompt: Press enter to continue From d02230af8176c3ff6ffc18f2770f150f4fb28f8d Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 8 Jul 2024 13:27:56 +0200 Subject: [PATCH 12/24] update --- playbooks/sap_hana_preconfigure_exec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index 9842e12c4..aa0621154 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -38,7 +38,7 @@ - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required | d('true') }}' - name: Pause Playbook to verify parameters - when: sap_playbook_parameter_confirm | d('false') | bool + when: sap_playbook_parameter_confirm | d(false) ansible.builtin.pause: prompt: Press enter to continue From 598efb330142d75feb44d0257cec0050e046620d Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 8 Jul 2024 14:38:45 +0200 Subject: [PATCH 13/24] Playbook Beautification --- playbooks/sap_hana_preconfigure_exec.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index aa0621154..f4e6eb7e8 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -29,12 +29,12 @@ ansible.builtin.debug: msg: |- The Hana setup runs with the following configuration - - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' - - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' - - 'Domain : {{ (sap_domain | d('') | length > 0) | ternary(sap_domain, ansible_domain) }}' - - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts | d('false') }}' - - 'Update OS : {{ sap_hana_preconfigure_update | d('false') }}' - - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok | d('false') }}' + - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' + - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' + - 'Domain : {{ (sap_domain | d('') | length > 0) | ternary(sap_domain, ansible_domain) }}' + - 'Modify hosts : {{ sap_general_preconfigure_modify_etc_hosts | d('false') }}' + - 'Update OS : {{ sap_hana_preconfigure_update | d('false') }}' + - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok | d('false') }}' - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required | d('true') }}' - name: Pause Playbook to verify parameters From 43d3110e50e17c3dcc93dd5afb2f1553af6f13a3 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Tue, 9 Jul 2024 16:39:14 +0200 Subject: [PATCH 14/24] fixed typo --- playbooks/README.md | 2 +- playbooks/sap_hana_preconfigure.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 542ff16fd..41425ae0f 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -58,4 +58,4 @@ Now you can run the playbook non-interactively with ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i my_inventory -e @my_vars.yml ``` -NOTE: If you do not define the parameter `sap_hana_group` the playbook will run against all hosts in the inventory unless limited with `-l hostname' or localhost if no inventory is defined. \ No newline at end of file +NOTE: If you do not define the parameter `sap_hana_group` the playbook will run against all hosts in the inventory unless limited with `-l hostname' or localhost if no inventory is defined. diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 9f28d7599..36c135810 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -6,7 +6,9 @@ # or alternatively unattended with # ansible-playbook community.sap_install.sap_hana_preconfigure -e @myvars.yml # -# The file myvars. yaml needs to contain the following variables +# The file myvars.yaml needs to contain the following variables +# +# please read README.md in playbooks folder for details # - name: Playbook Usage hosts: localhost From ead9d1c6de14ef45e0f2e16175712486ffbb7075 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Thu, 15 Aug 2024 15:13:23 +0200 Subject: [PATCH 15/24] added assert mode --- playbooks/sap_hana_preconfigure.yml | 71 +++++++++++++++++------------ 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 36c135810..becf0922d 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -12,6 +12,7 @@ # - name: Playbook Usage hosts: localhost + gather_facts: false tasks: - name: Playbook Usage ansible.builtin.debug: @@ -28,44 +29,54 @@ * sap_hana_preconfigure_exec.yml instead with a properly prepared variable * * file. (See README for more details) * ***************************************************************************** + "" - name: Collecting Variables hosts: localhost vars_prompt: - name: "sap_systems" - prompt: "Enter comma separated list of systems, you want to prepare for SAP HANA" + prompt: "Enter comma separated list of systems that you want to prepare for SAP HANA" private: false - default: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" + default: "{{ (groups['all'] == []) | ternary ('localhost', 'all') }}" + # default: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" - name: "sap_domain" - prompt: "Enter DNS Domainname of your SAP systems (leave empty for using system default: " + prompt: "Enter DNS Domainname of your SAP systems (leave empty for using system defaul): " private: false default: "{{ sap_domain | d('') }}" - - name: "sap_update_hosts" - prompt: "Do you want the system to update /etc/hosts for SAP (y/n)" - private: false - default: "y" - - - name: "sap_update" - prompt: "Do you want to update the system? (y/n)" - private: false - default: "n" - - - name: "sap_fail_if_reboot_required" - prompt: "Do you want to stop with an error if the system needs a reboot? (y/n)" - private: false - default: "n" - - - name: "sap_reboot" - prompt: "Do you want to reboot the system if required? (y/n)" + - name: "assert" + prompt: "Do you want to check the current setup only (assert mode)? (y/n)" private: false default: "n" tasks: + - name: Input addtional parameters if no assert mode is defined + when: assert != "y" + block: + - ansible.builtin.pause: # noqa name[missing] - role default true + prompt: "Do you want the system to update /etc/hosts for SAP? (y/n) [y]" + echo: true + register: _sap_update_hosts + - ansible.builtin.pause: # noqa name[missing] - role default false + prompt: "Do you want to update the system? (y/n) [n]" + echo: true + register: _sap_update + - ansible.builtin.pause: # noqa name[missing] - role default false + prompt: "Do you want to reboot the system if required? (y/n) [n]" + echo: true + register: _sap_reboot + - ansible.builtin.pause: # noqa name[missing] - role default true + prompt: "Do you want to stop with an error if the system needs a reboot? (y/n) [y]" + echo: true + register: _sap_fail_if_reboot_required + when: _sap_reboot.user_input != 'y' + - name: Prepare inventory - when: sap_systems != 'localhost' + when: + - sap_systems != 'localhost' + - sap_systems != 'all' ansible.builtin.add_host: groups: sap_hana_prepare_hosts name: '{{ item }}' @@ -75,25 +86,29 @@ ansible.builtin.set_fact: sap_domain: '{{ sap_domain }}' ### redhat.sap_install.sap_general_preconfigure - sap_general_preconfigure_modify_etc_hosts: '{{ (sap_update_hosts == "y") | ternary(true, false) }}' - sap_general_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' - sap_general_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' + sap_general_preconfigure_modify_etc_hosts: '{{ (_sap_update_hosts.user_input is defined) and (_sap_update_hosts.user_input == "n") | ternary(false, true) }}' # default true + sap_general_preconfigure_update: '{{ (_sap_update.user_input is defined) and (_sap_update.user_input == "y") | ternary(true, false) }}' # default false + sap_general_preconfigure_fail_if_reboot_required: '{{ (_sap_fail_if_reboot_required.user_input is defined) and (_sap_fail_if_reboot_required.user_input == "n") | ternary(false, true) }}' # default true + sap_general_preconfigure_assert: '{{ (assert=="y") | ternary(true,false) }}' # sap_general_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' ### redhat.sap_install.sap_hana_preconfigure - sap_hana_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' - sap_hana_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' - sap_hana_preconfigure_reboot_ok: '{{ (sap_reboot == "n") | ternary(false, true) }}' + sap_hana_preconfigure_update: '{{ (_sap_update.user_input is defined) and (_sap_update.user_input == "y") | ternary(true, false) }}' # default false + sap_hana_preconfigure_fail_if_reboot_required: '{{ (_sap_fail_if_reboot_required.user_input is defined) and (_sap_fail_if_reboot_required.user_input == "n") | ternary(false, true) }}' # default true + sap_hana_preconfigure_reboot_ok: '{{ (_sap_reboot.user_input is defined) and (_sap_reboot.user_input == "y") | ternary(true, false) }}' # default false + sap_hana_preconfigure_assert: '{{ (assert=="y") | ternary(true,false) }}' # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' - name: Run sap_hana_prepare_exec playbook ansible.builtin.import_playbook: sap_hana_preconfigure_exec.yml vars: sap_playbook_parameter_confirm: true - sap_hana_group: "{{ ( groups['sap_hana_prepare_hosts'] is defined) | ternary ('sap_hana_prepare_hosts','localhost') }}" + sap_hana_group: "{{ ( groups['sap_hana_prepare_hosts'] is defined) | ternary ('sap_hana_prepare_hosts',omit) }}" sap_domain: "{{ hostvars['localhost']['sap_domain'] }}" sap_general_preconfigure_modify_etc_hosts: "{{ hostvars['localhost']['sap_general_preconfigure_modify_etc_hosts'] }}" sap_general_preconfigure_update: "{{ hostvars['localhost']['sap_general_preconfigure_update'] }}" sap_general_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_general_preconfigure_fail_if_reboot_required'] }}" + sap_general_preconfigure_assert: "{{ hostvars['localhost']['sap_general_preconfigure_assert'] }}" sap_hana_preconfigure_update: "{{ hostvars['localhost']['sap_hana_preconfigure_update'] }}" sap_hana_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_hana_preconfigure_fail_if_reboot_required'] }}" sap_hana_preconfigure_reboot_ok: "{{ hostvars['localhost']['sap_hana_preconfigure_reboot_ok'] }}" + sap_hana_preconfigure_assert: "{{ hostvars['localhost']['sap_hana_preconfigure_assert'] }}" From 5cb5088d50329c6bac9090ef65165f7c1ddf598e Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Thu, 15 Aug 2024 15:25:57 +0200 Subject: [PATCH 16/24] changed assert behaviour --- playbooks/sap_hana_preconfigure.yml | 2 ++ playbooks/sap_hana_preconfigure_exec.yml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index becf0922d..b67681e25 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -108,7 +108,9 @@ sap_general_preconfigure_update: "{{ hostvars['localhost']['sap_general_preconfigure_update'] }}" sap_general_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_general_preconfigure_fail_if_reboot_required'] }}" sap_general_preconfigure_assert: "{{ hostvars['localhost']['sap_general_preconfigure_assert'] }}" + sap_general_preconfigure_assert_ignore_errors: true sap_hana_preconfigure_update: "{{ hostvars['localhost']['sap_hana_preconfigure_update'] }}" sap_hana_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_hana_preconfigure_fail_if_reboot_required'] }}" sap_hana_preconfigure_reboot_ok: "{{ hostvars['localhost']['sap_hana_preconfigure_reboot_ok'] }}" sap_hana_preconfigure_assert: "{{ hostvars['localhost']['sap_hana_preconfigure_assert'] }}" + sap_hana_preconfigure_assert_ignore_errors: true diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index f4e6eb7e8..7f10ae6ea 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -40,7 +40,6 @@ - name: Pause Playbook to verify parameters when: sap_playbook_parameter_confirm | d(false) ansible.builtin.pause: - prompt: Press enter to continue - name: Perform the general SAP configuration ansible.builtin.include_role: From 8ff11bf1a9f6fcd0b7655759f891e73f6edf4cb6 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Thu, 15 Aug 2024 15:32:50 +0200 Subject: [PATCH 17/24] Better Description --- playbooks/sap_hana_preconfigure.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index b67681e25..3d28e7bbc 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -36,7 +36,7 @@ vars_prompt: - name: "sap_systems" - prompt: "Enter comma separated list of systems that you want to prepare for SAP HANA" + prompt: "Enter comma separated list of systems that you want to check or prepare for SAP HANA" private: false default: "{{ (groups['all'] == []) | ternary ('localhost', 'all') }}" # default: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" From 4b03ec9783f9da6e2680b41dc287273ce6516395 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Wed, 28 Aug 2024 10:22:07 +0200 Subject: [PATCH 18/24] changes made to run completely with pause instead of vars_prompt. Based on user request --- playbooks/sap_hana_install.yml | 122 ---------------------------- playbooks/sap_hana_preconfigure.yml | 59 ++++++++------ 2 files changed, 35 insertions(+), 146 deletions(-) delete mode 100644 playbooks/sap_hana_install.yml diff --git a/playbooks/sap_hana_install.yml b/playbooks/sap_hana_install.yml deleted file mode 100644 index 46fd63043..000000000 --- a/playbooks/sap_hana_install.yml +++ /dev/null @@ -1,122 +0,0 @@ ---- -## -# Call this playbook interactively with -# ansible-playbook community.sap_install.sap_hana_preconfigure -# -# or alternatively unattended with -# ansible-playbook community.sap_install.sap_hana_preconfigure -e @myvars.yml -# -# The file myvars. yaml needs to contain the following variables -# -- name: Disclaimer - ansible.builtin.import_playbook: disclaimer.yml # TODO: check if FQDN is required/optional - when: sap_playbook_disclaimer | d('true') - -- name: Collecting Variables - hosts: localhost - - vars_prompt: - - name: "sap_domain" - prompt: "Enter Domainname of your SAP systems (leave empty for using system default: " - private: false - default: "{{ sap_domain | d('') }}" - - - name: "sap_update_hosts" - prompt: "Do you want the system to update /etc/hosts for SAP (y/n)" - private: false - default: "y" - - - name: "sap_update" - prompt: "Do you want to update the system? (y/n)" - private: false - default: "n" - - - name: "sap_fail_if_reboot_required" - prompt: "Do you want to stop with an error if the system needs a reboot? (y/n)" - private: false - default: "n" - - - name: "sap_reboot" - prompt: "Do you want to reboot the system if required? (y/n)" - private: false - default: "n" - - - name: "sap_path" - prompt: "Enter path to SAP HANA install files" - private: false - default: /sap-install - - - name: "sap_hana_sid" - prompt: "SAP HANA SID" - private: false - default: "HDB" - - - name: "sap_hana_instance_number" - prompt: "SAP HANA instance number" - private: false - default: "90" - - - name: "sap_pass" - prompt: "SAP HANA password" - private: true - unsafe: true - - tasks: - - name: Configure Role Variables - ansible.builtin.set_fact: - sap_domain: '{{ sap_domain }}' - ### redhat.sap_install.sap_general_preconfigure - sap_general_preconfigure_modify_etc_hosts: '{{ (sap_update_hosts == "y") | ternary(true, false) }}' - sap_general_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' - sap_general_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' - # sap_general_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' - ### redhat.sap_install.sap_hana_preconfigure - sap_hana_preconfigure_update: '{{ (sap_update == "y") | ternary(true, false) }}' - sap_hana_preconfigure_fail_if_reboot_required: '{{ (sap_fail_if_reboot_required == "n") | ternary(false, true) }}' - sap_hana_preconfigure_reboot_ok: '{{ (sap_reboot == "n") | ternary(false, true) }}' - # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' - ## BEGIN sap_hana_install parameters - sap_hana_install_software_directory: '{{ sap_path }}' - sap_hana_install_software_extract_directory: /tmp/sap-hana-inst - sap_hana_install_master_password: '{{ sap_pass }}' - sap_hana_sid: '{{ sap_hana_sid }}' - sap_hana_instance_number: '{{ sap_hana_instance_number }}' - # sap_hana_install_restrict_max_mem: 'y' - # sap_hana_install_max_mem: 38912 - # sap_hana_install_system_roles_collection: 'redhat.rhel_system_roles' -## END sap_hana_install parameters - -- name: Prepare system for SAP HANA Installation - hosts: "{{ target_group | d('localhost') }}" - become: true - - tasks: - - name: Ansible Role Configuration - ansible.builtin.debug: - msg: |- - The Hana setup runs with the following configuration - - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' - - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' - - 'Domain : {{ (sap_domain | length > 0) | ternary(sap_domain, ansible_domain) }}' - - 'Modify hosts: {{ sap_general_preconfigure_modify_etc_hosts }}' - - 'Update OS : {{ sap_hana_preconfigure_update }}' - - 'Auto Reboot : {{ sap_hana_preconfigure_reboot_ok }}' - - 'Fail if reboot is needed: {{ sap_hana_preconfigure_fail_if_reboot_required }}' - - 'Ansible Collection: {{ ansible_collection_name | d('undefined') }}' - - - name: Pause playbook execution to verify parameters - when: sap_playbook_disclaimer | d('true') - ansible.builtin.pause: - prompt: Press enter to continue - - - name: Prepare general preconfiguration - ansible.builtin.include_role: - name: community.sap_install.sap_general_preconfigure - - - name: Prepare system for HANA installation - ansible.builtin.include_role: - name: community.sap_install.sap_hana_preconfigure - - - name: Install SAP HANA - ansible.builtin.include_role: - name: community.sap_install.sap_hana_install diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 3d28e7bbc..5c8338f8d 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -31,29 +31,40 @@ ***************************************************************************** "" -- name: Collecting Variables +- name: Collecting Parameters for OS preparation or check to install SAP HANA hosts: localhost + gather_facts: false + + vars: + - sap_systems: "{{ (groups['all'] == []) | ternary ('localhost', 'all') }}" + # sap_systems: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" - vars_prompt: - - name: "sap_systems" - prompt: "Enter comma separated list of systems that you want to check or prepare for SAP HANA" - private: false - default: "{{ (groups['all'] == []) | ternary ('localhost', 'all') }}" - # default: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" + tasks: + - name: Get minimal facts + ansible.builtin.setup: + gather_subset: + - '!all' - - name: "sap_domain" - prompt: "Enter DNS Domainname of your SAP systems (leave empty for using system defaul): " - private: false - default: "{{ sap_domain | d('') }}" + - name: Target systems for hana installation + ansible.builtin.pause: + prompt: "Enter comma separated list of systems that you want to check or prepare for SAP HANA: [{{ sap_systems }}]" + echo: true + register: _sap_systems - - name: "assert" - prompt: "Do you want to check the current setup only (assert mode)? (y/n)" - private: false - default: "n" + - name: SAP server DNS domain must not be empty + ansible.builtin.pause: + prompt: "Enter DNS Domainname of your SAP systems: [{{ sap_domain | d(ansible_domain) }}]" + echo: true + register: _sap_domain + + - name: Run mode + ansible.builtin.pause: + prompt: "Do you want to check the current setup only (assert mode)? (y/n) [n]" + echo: true + register: _assert_mode - tasks: - name: Input addtional parameters if no assert mode is defined - when: assert != "y" + when: _assert_mode.user_input != "y" block: - ansible.builtin.pause: # noqa name[missing] - role default true prompt: "Do you want the system to update /etc/hosts for SAP? (y/n) [y]" @@ -75,34 +86,34 @@ - name: Prepare inventory when: - - sap_systems != 'localhost' - - sap_systems != 'all' + - _sap_systems.user_input is defined + - _sap_systems.user_input| trim != '' ansible.builtin.add_host: groups: sap_hana_prepare_hosts name: '{{ item }}' - loop: '{{ sap_systems | split(",") | list }}' + loop: '{{ _sap_systems.user_input | split(",") | list }}' - name: Configure Role Variables ansible.builtin.set_fact: - sap_domain: '{{ sap_domain }}' + sap_domain: '{{ ((_sap_domain.user_input | trim) != "") | ternary(_sap_domain.user_input, sap_domain | d(ansible_domain)) }}' ### redhat.sap_install.sap_general_preconfigure sap_general_preconfigure_modify_etc_hosts: '{{ (_sap_update_hosts.user_input is defined) and (_sap_update_hosts.user_input == "n") | ternary(false, true) }}' # default true sap_general_preconfigure_update: '{{ (_sap_update.user_input is defined) and (_sap_update.user_input == "y") | ternary(true, false) }}' # default false sap_general_preconfigure_fail_if_reboot_required: '{{ (_sap_fail_if_reboot_required.user_input is defined) and (_sap_fail_if_reboot_required.user_input == "n") | ternary(false, true) }}' # default true - sap_general_preconfigure_assert: '{{ (assert=="y") | ternary(true,false) }}' + sap_general_preconfigure_assert: '{{ (_assert_mode.user_input == "y") | ternary(true, false) }}' # sap_general_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' ### redhat.sap_install.sap_hana_preconfigure sap_hana_preconfigure_update: '{{ (_sap_update.user_input is defined) and (_sap_update.user_input == "y") | ternary(true, false) }}' # default false sap_hana_preconfigure_fail_if_reboot_required: '{{ (_sap_fail_if_reboot_required.user_input is defined) and (_sap_fail_if_reboot_required.user_input == "n") | ternary(false, true) }}' # default true sap_hana_preconfigure_reboot_ok: '{{ (_sap_reboot.user_input is defined) and (_sap_reboot.user_input == "y") | ternary(true, false) }}' # default false - sap_hana_preconfigure_assert: '{{ (assert=="y") | ternary(true,false) }}' + sap_hana_preconfigure_assert: '{{ (_assert_mode.user_input == "y") | ternary(true, false) }}' # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' - name: Run sap_hana_prepare_exec playbook ansible.builtin.import_playbook: sap_hana_preconfigure_exec.yml vars: sap_playbook_parameter_confirm: true - sap_hana_group: "{{ ( groups['sap_hana_prepare_hosts'] is defined) | ternary ('sap_hana_prepare_hosts',omit) }}" + sap_hana_group: "{{ (groups['sap_hana_prepare_hosts'] is defined) | ternary ('sap_hana_prepare_hosts',sap_systems) }}" sap_domain: "{{ hostvars['localhost']['sap_domain'] }}" sap_general_preconfigure_modify_etc_hosts: "{{ hostvars['localhost']['sap_general_preconfigure_modify_etc_hosts'] }}" sap_general_preconfigure_update: "{{ hostvars['localhost']['sap_general_preconfigure_update'] }}" From 063ab102ed3676322db494714fe5ef1a5f706f66 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Wed, 28 Aug 2024 10:25:44 +0200 Subject: [PATCH 19/24] Updates to readme --- playbooks/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 41425ae0f..7ffef9f50 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -17,8 +17,8 @@ ansible-playbook community.sap_install.sap_hana_preconfigure.yml ``` This playbook runs against localhost and/or remote hosts. -Remote hosts can be defined in an inventory in a file, or with -i on the commandline e.g. `-i inventoryfile` or `-i host1,host2,host3,` and execution can be of course limited with -l. -Nonetheless you need to confirm the hosts in the interactive dialog. +Remote hosts can be defined in an inventory file, or with -i on the commandline e.g. `-i inventoryfile` or `-i host1,host2,host3,` and execution can be limited with -l. +You need to confirm the hosts in the interactive dialog. When you call this playbook against a remote host make sure the user can connect and assume root without a password or pass the following parameters if necessary ```[bash] @@ -38,7 +38,7 @@ hana2 ``` Prepare a variable config file with the following parameters (adapt to your needs): -Create a parameter file `my_vars` with similar content: +Create a parameter file `my_vars.yml` with similar content: ```[yaml] # sap_playbook_parameter_confirm: false From 45391cb367ee936775fcf44553ac5ab4d1408f64 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Wed, 28 Aug 2024 10:42:37 +0200 Subject: [PATCH 20/24] output beautification --- playbooks/sap_hana_preconfigure.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 5c8338f8d..84d3d94e3 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -14,9 +14,9 @@ hosts: localhost gather_facts: false tasks: - - name: Playbook Usage + - name: Playbook Usage # noqa trailing-spaces ansible.builtin.debug: - msg: |- + msg: |+ ***************************************************************************** * sap_hana_preconfigure * * * @@ -29,7 +29,6 @@ * sap_hana_preconfigure_exec.yml instead with a properly prepared variable * * file. (See README for more details) * ***************************************************************************** - "" - name: Collecting Parameters for OS preparation or check to install SAP HANA hosts: localhost From fbc4bbc6441a1fb6bc78cd7e6a0611daf96fe8e6 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Wed, 28 Aug 2024 10:54:13 +0200 Subject: [PATCH 21/24] codespell corrections --- playbooks/README.md | 2 +- playbooks/sap_hana_preconfigure.yml | 4 ++-- playbooks/sap_hana_preconfigure_exec.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 7ffef9f50..7ebccf8f8 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -24,7 +24,7 @@ When you call this playbook against a remote host make sure the user can connect ```[bash] -u : User that establishes the ssh connection -k: asks for password or passphrase of the connection user, if required for ssh - -K: asks for the privilige escalation password of the connection user to become root on the target host + -K: asks for the privilege escalation password of the connection user to become root on the target host ``` If you want to embed this playbook or run a non-interactive version, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml index 84d3d94e3..159acf890 100644 --- a/playbooks/sap_hana_preconfigure.yml +++ b/playbooks/sap_hana_preconfigure.yml @@ -21,7 +21,7 @@ * sap_hana_preconfigure * * * * This playbook is used to prepare an SAP HANA system. * - * The minimum viable parameters to succussfully prepare your system for an * + * The minimum viable parameters to successfully prepare your system for an * * SAP HANA installation will be asked. * * Useful defaults will be set, so that it is save to just press enter * * * @@ -62,7 +62,7 @@ echo: true register: _assert_mode - - name: Input addtional parameters if no assert mode is defined + - name: Input additional parameters if no assert mode is defined when: _assert_mode.user_input != "y" block: - ansible.builtin.pause: # noqa name[missing] - role default true diff --git a/playbooks/sap_hana_preconfigure_exec.yml b/playbooks/sap_hana_preconfigure_exec.yml index 7f10ae6ea..b70cf2a39 100644 --- a/playbooks/sap_hana_preconfigure_exec.yml +++ b/playbooks/sap_hana_preconfigure_exec.yml @@ -30,7 +30,7 @@ msg: |- The Hana setup runs with the following configuration - 'Hostname : {{ sap_hostname | d(ansible_hostname) }}' - - 'IP Adress : {{ sap_ip | d(ansible_default_ipv4.address) }}' + - 'IP Address : {{ sap_ip | d(ansible_default_ipv4.address) }}' - 'Domain : {{ (sap_domain | d('') | length > 0) | ternary(sap_domain, ansible_domain) }}' - 'Modify hosts : {{ sap_general_preconfigure_modify_etc_hosts | d('false') }}' - 'Update OS : {{ sap_hana_preconfigure_update | d('false') }}' From a865c66f7fd0bf5f9ff4e95be5f88406952eb060 Mon Sep 17 00:00:00 2001 From: rhmk Date: Wed, 11 Sep 2024 12:16:59 +0200 Subject: [PATCH 22/24] removed interactive version on request from @seanfreeman --- playbooks/sap_hana_preconfigure.yml | 126 ---------------------------- 1 file changed, 126 deletions(-) delete mode 100644 playbooks/sap_hana_preconfigure.yml diff --git a/playbooks/sap_hana_preconfigure.yml b/playbooks/sap_hana_preconfigure.yml deleted file mode 100644 index 159acf890..000000000 --- a/playbooks/sap_hana_preconfigure.yml +++ /dev/null @@ -1,126 +0,0 @@ ---- -## -# Call this playbook interactively with -# ansible-playbook community.sap_install.sap_hana_preconfigure -# -# or alternatively unattended with -# ansible-playbook community.sap_install.sap_hana_preconfigure -e @myvars.yml -# -# The file myvars.yaml needs to contain the following variables -# -# please read README.md in playbooks folder for details -# -- name: Playbook Usage - hosts: localhost - gather_facts: false - tasks: - - name: Playbook Usage # noqa trailing-spaces - ansible.builtin.debug: - msg: |+ - ***************************************************************************** - * sap_hana_preconfigure * - * * - * This playbook is used to prepare an SAP HANA system. * - * The minimum viable parameters to successfully prepare your system for an * - * SAP HANA installation will be asked. * - * Useful defaults will be set, so that it is save to just press enter * - * * - * If you want to run these steps unattended, please use the playbook * - * sap_hana_preconfigure_exec.yml instead with a properly prepared variable * - * file. (See README for more details) * - ***************************************************************************** - -- name: Collecting Parameters for OS preparation or check to install SAP HANA - hosts: localhost - gather_facts: false - - vars: - - sap_systems: "{{ (groups['all'] == []) | ternary ('localhost', 'all') }}" - # sap_systems: "{{ (groups['all'] == []) | ternary ('localhost', groups['all'] | join(',')) }}" - - tasks: - - name: Get minimal facts - ansible.builtin.setup: - gather_subset: - - '!all' - - - name: Target systems for hana installation - ansible.builtin.pause: - prompt: "Enter comma separated list of systems that you want to check or prepare for SAP HANA: [{{ sap_systems }}]" - echo: true - register: _sap_systems - - - name: SAP server DNS domain must not be empty - ansible.builtin.pause: - prompt: "Enter DNS Domainname of your SAP systems: [{{ sap_domain | d(ansible_domain) }}]" - echo: true - register: _sap_domain - - - name: Run mode - ansible.builtin.pause: - prompt: "Do you want to check the current setup only (assert mode)? (y/n) [n]" - echo: true - register: _assert_mode - - - name: Input additional parameters if no assert mode is defined - when: _assert_mode.user_input != "y" - block: - - ansible.builtin.pause: # noqa name[missing] - role default true - prompt: "Do you want the system to update /etc/hosts for SAP? (y/n) [y]" - echo: true - register: _sap_update_hosts - - ansible.builtin.pause: # noqa name[missing] - role default false - prompt: "Do you want to update the system? (y/n) [n]" - echo: true - register: _sap_update - - ansible.builtin.pause: # noqa name[missing] - role default false - prompt: "Do you want to reboot the system if required? (y/n) [n]" - echo: true - register: _sap_reboot - - ansible.builtin.pause: # noqa name[missing] - role default true - prompt: "Do you want to stop with an error if the system needs a reboot? (y/n) [y]" - echo: true - register: _sap_fail_if_reboot_required - when: _sap_reboot.user_input != 'y' - - - name: Prepare inventory - when: - - _sap_systems.user_input is defined - - _sap_systems.user_input| trim != '' - ansible.builtin.add_host: - groups: sap_hana_prepare_hosts - name: '{{ item }}' - loop: '{{ _sap_systems.user_input | split(",") | list }}' - - - name: Configure Role Variables - ansible.builtin.set_fact: - sap_domain: '{{ ((_sap_domain.user_input | trim) != "") | ternary(_sap_domain.user_input, sap_domain | d(ansible_domain)) }}' - ### redhat.sap_install.sap_general_preconfigure - sap_general_preconfigure_modify_etc_hosts: '{{ (_sap_update_hosts.user_input is defined) and (_sap_update_hosts.user_input == "n") | ternary(false, true) }}' # default true - sap_general_preconfigure_update: '{{ (_sap_update.user_input is defined) and (_sap_update.user_input == "y") | ternary(true, false) }}' # default false - sap_general_preconfigure_fail_if_reboot_required: '{{ (_sap_fail_if_reboot_required.user_input is defined) and (_sap_fail_if_reboot_required.user_input == "n") | ternary(false, true) }}' # default true - sap_general_preconfigure_assert: '{{ (_assert_mode.user_input == "y") | ternary(true, false) }}' - # sap_general_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' - ### redhat.sap_install.sap_hana_preconfigure - sap_hana_preconfigure_update: '{{ (_sap_update.user_input is defined) and (_sap_update.user_input == "y") | ternary(true, false) }}' # default false - sap_hana_preconfigure_fail_if_reboot_required: '{{ (_sap_fail_if_reboot_required.user_input is defined) and (_sap_fail_if_reboot_required.user_input == "n") | ternary(false, true) }}' # default true - sap_hana_preconfigure_reboot_ok: '{{ (_sap_reboot.user_input is defined) and (_sap_reboot.user_input == "y") | ternary(true, false) }}' # default false - sap_hana_preconfigure_assert: '{{ (_assert_mode.user_input == "y") | ternary(true, false) }}' - # sap_hana_preconfigure_system_roles_collection: 'redhat.rhel_system_roles' - -- name: Run sap_hana_prepare_exec playbook - ansible.builtin.import_playbook: sap_hana_preconfigure_exec.yml - vars: - sap_playbook_parameter_confirm: true - sap_hana_group: "{{ (groups['sap_hana_prepare_hosts'] is defined) | ternary ('sap_hana_prepare_hosts',sap_systems) }}" - sap_domain: "{{ hostvars['localhost']['sap_domain'] }}" - sap_general_preconfigure_modify_etc_hosts: "{{ hostvars['localhost']['sap_general_preconfigure_modify_etc_hosts'] }}" - sap_general_preconfigure_update: "{{ hostvars['localhost']['sap_general_preconfigure_update'] }}" - sap_general_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_general_preconfigure_fail_if_reboot_required'] }}" - sap_general_preconfigure_assert: "{{ hostvars['localhost']['sap_general_preconfigure_assert'] }}" - sap_general_preconfigure_assert_ignore_errors: true - sap_hana_preconfigure_update: "{{ hostvars['localhost']['sap_hana_preconfigure_update'] }}" - sap_hana_preconfigure_fail_if_reboot_required: "{{ hostvars['localhost']['sap_hana_preconfigure_fail_if_reboot_required'] }}" - sap_hana_preconfigure_reboot_ok: "{{ hostvars['localhost']['sap_hana_preconfigure_reboot_ok'] }}" - sap_hana_preconfigure_assert: "{{ hostvars['localhost']['sap_hana_preconfigure_assert'] }}" - sap_hana_preconfigure_assert_ignore_errors: true From f6800171941687538ba49bea30efdb0eb16e9cb2 Mon Sep 17 00:00:00 2001 From: rhmk Date: Wed, 11 Sep 2024 14:13:10 +0200 Subject: [PATCH 23/24] Updated README file, how to use the playbooks --- playbooks/README.md | 71 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/playbooks/README.md b/playbooks/README.md index 7ebccf8f8..09fc946dd 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -1,48 +1,26 @@ # Ansible Collection Playbooks -The playbooks in this directory can be used as templates for your own playbooks -(starting with sample-) and some can be called directly with interactive variable collection -or included in your own playbooks or workflows. +The playbooks starting with `sample-` in this directory can be used as examples for your own playbooksi and cannot be called directly from the commandline. +The other playbooks can be called directly with a prepared variable file or imported in your own playbooks or workflows. +The playbooks can run agianst localhost, all hosts or defined group. ## Usage of playbooks -### Prepare System for SAP HANA installation (sap_hana_prepare.yml/sap_hana_prepare_exec.yml) - -This playbook collects information for preparing an SAP system for an SAP HANA installation. -Run the following command: - -```[bash] -ansible-playbook community.sap_install.sap_hana_preconfigure.yml -``` +### Prepare System for SAP HANA installation: `sap_hana_prepare_exec.yml` This playbook runs against localhost and/or remote hosts. -Remote hosts can be defined in an inventory file, or with -i on the commandline e.g. `-i inventoryfile` or `-i host1,host2,host3,` and execution can be limited with -l. -You need to confirm the hosts in the interactive dialog. -When you call this playbook against a remote host make sure the user can connect and assume root without a password or pass the following parameters if necessary +You need to define the variable `sap_hana_group`to run this playbook against a particular group of hosts which is defined in your inventory. +If you do not define the parameter `sap_hana_group` the playbook will run against all hosts in the inventory unless limited with `-l hostname' or localhost if no inventory is defined. -```[bash] - -u : User that establishes the ssh connection - -k: asks for password or passphrase of the connection user, if required for ssh - -K: asks for the privilege escalation password of the connection user to become root on the target host -``` +To run this playbook you need to prepare a variable file with a minimum viable set of variables. -If you want to embed this playbook or run a non-interactive version, you need to prepare an ansible inventory that contains a group for the hosts you want to install, e.g. my_hanas (see also ). +#### Example: -Create the file `my_inventory` similar to: - -```[yaml] -[my_hanas] -hana1 -hana2 -``` - -Prepare a variable config file with the following parameters (adapt to your needs): Create a parameter file `my_vars.yml` with similar content: ```[yaml] - # sap_playbook_parameter_confirm: false - sap_hana_group: 'my_hanas' + # sap_playbook_parameter_confirm: false # Set to true if you want to list parameters and confirm execution sap_domain: my.sap.domain sap_general_preconfigure_modify_etc_hosts: true sap_general_preconfigure_update: true @@ -52,10 +30,35 @@ Create a parameter file `my_vars.yml` with similar content: sap_hana_preconfigure_reboot_ok: true ``` -Now you can run the playbook non-interactively with +Create the file `my_inventory` similar to: + +```[yaml] +[my_hanas] +hana1 +hana2 +``` + +Now you can run the playbook with ```[bash] -ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i my_inventory -e @my_vars.yml +ansible-playbook community.sap_install.sap_hana_preconfigure_exec.yml -i my_inventory -e @my_vars.yml -e sap_hana_group=my_hanas +``` + +When you call this playbook against a remote host make sure the user can connect and assume root without a password or pass the following parameters if necessary + +```[bash] + -u : User that establishes the ssh connection + -k: asks for password or passphrase of the connection user, if required for ssh + -K: asks for the privilege escalation password of the connection user to become root on the target host +``` + +You can also call the playbook inside another playbook with: + +``` +- name: Include HANA preparation from collection for group my_hanas + ansible.builtin.import_playbook: community.sap_install.sap_hana_prepare_exec.yml + vars: + sap_hana_group: my_hanas + # add other vars here, or define somewhere else ``` -NOTE: If you do not define the parameter `sap_hana_group` the playbook will run against all hosts in the inventory unless limited with `-l hostname' or localhost if no inventory is defined. From 6f0b681b6b2c70835dc8885941fe5624ef75837b Mon Sep 17 00:00:00 2001 From: rhmk Date: Wed, 11 Sep 2024 14:15:58 +0200 Subject: [PATCH 24/24] codespell fix --- playbooks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/README.md b/playbooks/README.md index 09fc946dd..02987c363 100644 --- a/playbooks/README.md +++ b/playbooks/README.md @@ -3,7 +3,7 @@ The playbooks starting with `sample-` in this directory can be used as examples for your own playbooksi and cannot be called directly from the commandline. The other playbooks can be called directly with a prepared variable file or imported in your own playbooks or workflows. -The playbooks can run agianst localhost, all hosts or defined group. +The playbooks can run against localhost, all hosts or defined group. ## Usage of playbooks