Skip to content

Commit

Permalink
sap_hostagent: ansible-lint 6.22.0 cleanup
Browse files Browse the repository at this point in the history
Relates to #535.

Signed-off-by: Bernd Finger <[email protected]>
  • Loading branch information
berndfinger committed Dec 15, 2023
1 parent a605485 commit da862bd
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 40 deletions.
3 changes: 3 additions & 0 deletions roles/sap_hostagent/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
exclude_paths:
- tests/
enable_list:
- yaml
skip_list:
- meta-runtime[unsupported-version] # We don't want to enforce new Ansible versions for Galaxy
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable
- schema # We want to allow single digit version numbers in a role's meta/main.yml file. This is allowed as per https://galaxy.ansible.com/docs/contributing/creating_role.html and https://galaxy.ansible.com/api/v1/platforms/?page=6.
- name[template] # Allow templating inside name. During dev and qa, it should be possible to identify cases where it doesn't work
3 changes: 2 additions & 1 deletion roles/sap_hostagent/tasks/common_post.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---

# Ensure {{ sap_hostagent_agent_tmp_directory }} directory is removed from the target host
- name: Ensure {{ sap_hostagent_agent_tmp_directory }} directory does not exist
file:
ansible.builtin.file:
path: "{{ sap_hostagent_agent_tmp_directory }}"
state: absent
mode: '0755'
Expand Down
4 changes: 2 additions & 2 deletions roles/sap_hostagent/tasks/common_pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Ensure {{ sap_hostagent_agent_tmp_directory }} directory exists on the target host
- name: Ensure {{ sap_hostagent_agent_tmp_directory }} directory exists
file:
ansible.builtin.file:
path: "{{ sap_hostagent_agent_tmp_directory }}"
state: directory
mode: '0755'
mode: '0755'
18 changes: 9 additions & 9 deletions roles/sap_hostagent/tasks/config_ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Ensure 'sapadm' user home directory exists
- name: Ensure 'sapadm' user home directory exists
file:
ansible.builtin.file:
path: "/home/sapadm"
state: directory
mode: '0755'
Expand All @@ -12,20 +12,20 @@
# Ensure SSL is configured for agent communication
# https://help.sap.com/viewer/6e1636d91ccc458c987094ee1fb864ae/HAG_CURRENT_VERSION/en-US/6aac42c2e742413da050eaecd57f785d.html
- name: Prepare the Personal Security Environment (PSE) for the server
file:
ansible.builtin.file:
path: "/usr/sap/hostctrl/exe/sec"
state: directory
mode: '0755'
owner: sapadm
group: sapsys

- name: Ensure any previous PSE generated by this role does not exists
file:
ansible.builtin.file:
path: /usr/sap/hostctrl/exe/sec/SAPSSLS.pse
state: absent

- name: Create the server PSE, the server certificate therein, and the Certificate Signing Request (CSR)
command: >
ansible.builtin.command: >
/usr/sap/hostctrl/exe/sapgenpse gen_pse
-p SAPSSLS.pse
-x "{{ sap_hostagent_ssl_passwd }}"
Expand All @@ -42,7 +42,7 @@
changed_when: "'Certificate Request:' in ssl_config_output.stdout"

- name: Grant SAP Host Agent access to the server PSE
command: >
ansible.builtin.command: >
/usr/sap/hostctrl/exe/sapgenpse seclogin
-p SAPSSLS.pse
-x "{{ sap_hostagent_ssl_passwd }}"
Expand All @@ -59,9 +59,9 @@

# Right now there is no option to import teh signed certificate. The CSR must be signed
# by a valid CA in order to import it
#
#
# - name: Import the signed certificate into the server PSE
# command: >
# ansible.builtin.command: >
# /usr/sap/hostctrl/exe/sapgenpse import_own_cert
# -p SAPSSLS.pse
# -x "{{ sap_hostagent_ssl_passwd }}"
Expand All @@ -74,7 +74,7 @@
# SECUDIR: /usr/sap/hostctrl/exe/sec

- name: Verify the server certificate chain
command: >
ansible.builtin.command: >
/usr/sap/hostctrl/exe/sapgenpse get_my_name
-x "{{ sap_hostagent_ssl_passwd }}"
-v
Expand All @@ -89,6 +89,6 @@
changed_when: "'Opening PSE' in ssl_config_output.stdout"

- name: Restart SAPHOSTAGENT
command: /usr/sap/hostctrl/exe/saphostexec -restart
ansible.builtin.command: /usr/sap/hostctrl/exe/saphostexec -restart
register: ssl_config_output
changed_when: "'start hostcontrol using profile' in ssl_config_output.stdout"
6 changes: 3 additions & 3 deletions roles/sap_hostagent/tasks/deploy_bundle.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---

- name: Extract the SAPHOSTAGENT TGZ file from the Bundle
unarchive:
ansible.builtin.unarchive:
src: "{{ sap_hostagent_bundle_path }}/HOSTAGENT.TGZ"
dest: "{{ sap_hostagent_agent_tmp_directory }}"
remote_src: yes
mode: '0755'

- name: Install SAPHOSTAGENT
command: "{{ sap_hostagent_agent_tmp_directory }}/global/hdb/saphostagent_setup/saphostexec -install"
ansible.builtin.command: "{{ sap_hostagent_agent_tmp_directory }}/global/hdb/saphostagent_setup/saphostexec -install"
register: installagent
args:
chdir: "{{ sap_hostagent_agent_tmp_directory }}/global/hdb/saphostagent_setup/"
changed_when: "'Install service' in installagent.stdout"
changed_when: "'Install service' in installagent.stdout"
8 changes: 4 additions & 4 deletions roles/sap_hostagent/tasks/deploy_rpm.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---

- name: Copy RPM based SAPHOSTAGENT to the target host
copy:
ansible.builtin.copy:
src: "{{ sap_hostagent_rpm_local_path }}/{{ sap_hostagent_rpm_file_name }}"
dest: "{{ sap_hostagent_agent_tmp_directory }}/{{ sap_hostagent_rpm_file_name }}"
mode: '0755'
when: sap_hostagent_rpm_local_path is defined

- name: Ensure RPM file is installed
yum:
ansible.builtin.yum:
name: "{{ sap_hostagent_agent_tmp_directory }}/{{ sap_hostagent_rpm_file_name }}"
state: present
disable_gpg_check: yes
when: sap_hostagent_rpm_local_path is defined

- name: Ensure RPM file is installed
yum:
ansible.builtin.yum:
name: "{{ sap_hostagent_rpm_remote_path }}/{{ sap_hostagent_rpm_file_name }}"
state: present
disable_gpg_check: yes
when: sap_hostagent_rpm_remote_path is defined
when: sap_hostagent_rpm_remote_path is defined
10 changes: 5 additions & 5 deletions roles/sap_hostagent/tasks/deploy_sar.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---

- name: Copy SAR based SAPHOSTAGENT to the target host
copy:
ansible.builtin.copy:
src: "{{ sap_hostagent_sar_local_path }}/{{ sap_hostagent_sar_file_name }}"
dest: "{{ sap_hostagent_agent_tmp_directory }}/{{ sap_hostagent_sar_file_name }}"
mode: '0755'

- name: Copy SAPCAR tool to the target host
copy:
ansible.builtin.copy:
src: "{{ sap_hostagent_sapcar_local_path }}/{{ sap_hostagent_sapcar_file_name }}"
dest: "{{ sap_hostagent_agent_tmp_directory }}/{{ sap_hostagent_sapcar_file_name }}"
mode: '0755'

- name: Extract the SAPHOSTAGENT archive using SAPCAR
command: >-
ansible.builtin.command: >-
{{ sap_hostagent_agent_tmp_directory }}/{{ sap_hostagent_sapcar_file_name }} \
-xvf {{ sap_hostagent_agent_tmp_directory }}/{{ sap_hostagent_sar_file_name }} -manifest SIGNATURE.SMF
register: extractagent
Expand All @@ -22,8 +22,8 @@
changed_when: "'SAPCAR: processing archive' in extractagent.stdout"

- name: Install SAPHOSTAGENT
command: "{{ sap_hostagent_agent_tmp_directory }}/saphostexec -install"
ansible.builtin.command: "{{ sap_hostagent_agent_tmp_directory }}/saphostexec -install"
register: installagent
args:
chdir: "{{ sap_hostagent_agent_tmp_directory }}"
changed_when: "'Install service' in installagent.stdout"
changed_when: "'Install service' in installagent.stdout"
4 changes: 2 additions & 2 deletions roles/sap_hostagent/tasks/deploy_sar_remote.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: Extract the SAPHOSTAGENT archive using SAPCAR
command: >-
ansible.builtin.command: >-
{{ sap_hostagent_sapcar_remote_path }}/{{ sap_hostagent_sapcar_file_name }} \
-xvf {{ sap_hostagent_sar_remote_path }}/{{ sap_hostagent_sar_file_name }} -manifest SIGNATURE.SMF
register: extractagent
Expand All @@ -10,7 +10,7 @@
changed_when: "'SAPCAR: processing archive' in extractagent.stdout"

- name: Install SAPHOSTAGENT
command: "{{ sap_hostagent_agent_tmp_directory }}/saphostexec -install"
ansible.builtin.command: "{{ sap_hostagent_agent_tmp_directory }}/saphostexec -install"
register: installagent
args:
chdir: "{{ sap_hostagent_agent_tmp_directory }}"
Expand Down
28 changes: 14 additions & 14 deletions roles/sap_hostagent/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
---

# Execute common pre installation tasks
- import_tasks: common_pre.yml
- name: Execute common pre installation tasks
ansible.builtin.import_tasks: common_pre.yml

# Deploy SAPHOSTAGENT using RPM file
- import_tasks: deploy_rpm.yml
- name: Deploy SAPHOSTAGENT using RPM file
ansible.builtin.import_tasks: deploy_rpm.yml
when: sap_hostagent_installation_type == "rpm"

# Deploy SAPHOSTAGENT using SAR file
- import_tasks: deploy_sar.yml
- name: Deploy SAPHOSTAGENT using SAR file
ansible.builtin.import_tasks: deploy_sar.yml
when: sap_hostagent_installation_type == "sar"

# Deploy SAPHOSTAGENT using SAR file existing on system
- import_tasks: deploy_sar_remote.yml
- name: Deploy SAPHOSTAGENT using SAR file existing on system
ansible.builtin.import_tasks: deploy_sar_remote.yml
when: sap_hostagent_installation_type == "sar-remote"

# Deploy SAPHOSTAGENT using SAP Installation Bundle
- import_tasks: deploy_bundle.yml
- name: Deploy SAPHOSTAGENT using SAP Installation Bundle
ansible.builtin.import_tasks: deploy_bundle.yml
when: sap_hostagent_installation_type == "bundle"

# Configuring SSL for SAP Host Agent
- import_tasks: config_ssl.yml
- name: Configure SSL for SAP Host Agent
ansible.builtin.import_tasks: config_ssl.yml
when: sap_hostagent_config_ssl

# Execute common post installation tasks
- import_tasks: common_post.yml
- name: Execute common post installation tasks
ansible.builtin.import_tasks: common_post.yml
3 changes: 3 additions & 0 deletions roles/sap_maintain_etc_hosts/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
exclude_paths:
- tests/
enable_list:
- yaml
skip_list:
- meta-runtime[unsupported-version] # We don't want to enforce new Ansible versions for Galaxy
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable
- schema # We want to allow single digit version numbers in a role's meta/main.yml file. This is allowed as per https://galaxy.ansible.com/docs/contributing/creating_role.html and https://galaxy.ansible.com/api/v1/platforms/?page=6.
- name[template] # Allow templating inside name. During dev and qa, it should be possible to identify cases where it doesn't work

0 comments on commit da862bd

Please sign in to comment.