ansible.openmanage/tasks/main.yml

171 lines
5.8 KiB
YAML

---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# tasks file for openmanage
# Manage repository [[[1
## Add repository
- name: Add OpenManage repository
ansible.builtin.apt_repository:
update_cache: false
repo: '{{ item.repo }}'
mode: '{{ item.mode | d(omit) }}'
filename: '{{ item.filename | d(omit) }}'
state: '{{ item.state | d("present") }}'
with_flattened:
- '{{ openmanage__repositories }}'
register: openmanage__register_repositories
until: openmanage__register_repositories is success
## Add repository key
### Don't remove the APT key, cause differents repos can have the same key
- name: Add OpenManage repo key
ansible.builtin.apt_key:
url: '{{ item.key_url | d(omit) }}'
id: '{{ item.key_id | d(omit) }}'
keyring: '/etc/apt/trusted.gpg.d/linux.dell.com.gpg'
keyserver: '{{ item.key_keyserver | d(omit) }}'
with_flattened:
- '{{ openmanage__repositories }}'
register: openmanage__register_key
until: openmanage__register_key is success
when: (openmanage__deploy_state == "present")
## Update cache
- name: Update APT cache
ansible.builtin.apt:
update_cache: '{{ true
if (openmanage__register_key is changed or
openmanage__register_repositories is changed)
else
false }}'
register: openmanage__register_update
until: openmanage__register_update is success
when: (openmanage__deploy_state == "present")
# Manage packages [[[1
## Manage depencies packages
- name: Ensure dependencies are present
ansible.builtin.package:
name: '{{ openmanage__dep_packages | flatten }}'
state: "present"
install_recommends: '{{ openmanage__install_recommends | bool }}'
register: pkg_dep_result
until: pkg_dep_result is success
when: (openmanage__deploy_state == "present")
## Manage Debian Stretch (or Ubuntu Xenial) specific packages
- name: "Ensure 910 specific packages (Stretch|Xenial) are in there desired state"
ansible.builtin.package:
name: '{{ openmanage__stretch_packages | flatten }}'
state: "present"
install_recommends: '{{ openmanage__install_recommends | bool }}'
register: pkg_stretch_result
until: pkg_stretch_result is success
when: (openmanage__deploy_state == "present" and
( (ansible_distribution == "Debian" and ansible_distribution_major_version is version("9", "<=")) or
(ansible_distribution == "Ubuntu" and ansible_distribution_version is version("16.04", "<="))))
## Manage base system packages
- name: Ensure base packages are in there desired state
ansible.builtin.package:
name: '{{ openmanage__base_packages | flatten }}'
state: '{{ "present" if (openmanage__deploy_state == "present") else "absent" }}'
install_recommends: '{{ openmanage__install_recommends | bool }}'
register: pkg_base_result
until: pkg_base_result is success
## Manage OMSA webgui packages
- name: Ensure OMSA-webgui packages are in there desired state
ansible.builtin.package:
name: '{{ openmanage__webgui_packages | flatten }}'
state: '{{ "present" if (openmanage__deploy_state == "present") and
(openmanage__webgui_state == "present")
else "absent" }}'
install_recommends: '{{ openmanage__install_recommends | bool }}'
register: pkg_webgui_result
until: pkg_webgui_result is success
notify: ['restart webgui service']
## Remove all OpenManage packages if requested
- name: Gather the Package facts
ansible.builtin.package_facts:
manager: auto
- name: Ensure to remove OpenManage related packages if requested
ansible.builtin.package:
name: 'srvadmin*'
state: "absent"
register: pkg_remove_result
until: pkg_remove_result is success
when:
- (openmanage__deploy_state == "absent")
- "'srvadmin' in ansible_facts.packages"
# Manage configuration [[[1
- name: Create SNMPD custom directory for systemd service
ansible.builtin.file:
path: "{{ openmanage__snmpd_service_override_path | dirname }}"
state: directory
mode: '0755'
when:
- openmanage__deploy_state == "present"
- ansible_distribution_release in ["buster"]
- name: Add SNMPD systemd custom configuration
ansible.builtin.template:
src: '{{ openmanage__snmpd_service_override_content }}'
dest: '{{ openmanage__snmpd_service_override_path }}'
owner: 'root'
group: 'root'
mode: '0644'
register: openmanage__snmpd_register_systemd_custom
when:
- openmanage__deploy_state == "present"
- ansible_distribution_release in ["buster"]
notify: ['Restart snmpd service']
# Executable [[[1
## Fix some permissions
- name: Ensure Executables can be run
ansible.builtin.file:
path: /opt/dell/srvadmin/sbin/racadm-wrapper-idrac7
mode: 0755
when: (openmanage__deploy_state == "present")
## Fix RAC1170 error
- name: Fix libssl error RAC1170
ansible.builtin.file:
src: "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.2"
path: "/opt/dell/srvadmin/lib64/libssl.so"
state: link
when: (openmanage__deploy_state == "present" and
( (ansible_distribution == "Debian" and ansible_distribution_major_version is version("9", "<=")) or
(ansible_distribution == "Ubuntu" and ansible_distribution_version is version("16.04", "<="))))
## Manage symlinks for OpenManage/racadm apps
- name: Ensure some Executables are in PATH
ansible.builtin.file:
src: "/opt/dell/srvadmin/sbin/{{ item }}"
path: "/bin/{{ item }}"
state: "link"
with_items:
- 'omconfig'
- 'omexec'
- 'omreport'
- 'omupdate'
- 'racadm'
when: (openmanage__deploy_state == "present")
- name: Remove Executables symlinks
ansible.builtin.file:
path: "/bin/{{ item }}"
state: "absent"
with_items:
- 'omconfig'
- 'omexec'
- 'omreport'
- 'omupdate'
- 'racadm'
when: (openmanage__deploy_state == "absent")