Ensure to remove service management if deploy state is "absent"
This commit is contained in:
parent
394b2ecdb5
commit
6cb121a5ea
|
@ -8,6 +8,7 @@
|
|||
|
||||
### Enhancements
|
||||
* Set a var to manage the state of the deployment by this role.
|
||||
* Ensure to remove service management if deploy state is "absent".
|
||||
|
||||
## v1.0
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ A role to manage Flexlm daemon.
|
|||
* **flexlm__lmutil_path** : The place to store `lmutil` bin [default : `/usr/local/bin/lmutil`].
|
||||
* **flexlm__user_name** : Username used to launch `lmgrd` [default : `flexlm`].
|
||||
* **flexlm__licences** : Lists to manage vendor daemon and licence files [default : `[]`].
|
||||
* **flexlm__service_manage** : If Licence Manager service should be managed with this role [default : `True`].
|
||||
* **flexlm__service_enabled** : If Licence Manager service should be enable at startup [default : `True`].
|
||||
* **flexlm__service_unit_content** : Template used to generate the previous file [default : `etc/systemd/system/flexlm.service.j2`].
|
||||
|
||||
## Example Playbook
|
||||
|
|
|
@ -26,17 +26,62 @@ flexlm__required_packages:
|
|||
flexlm__deploy_state: 'present'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Server configuration [[[
|
||||
# ------------------------
|
||||
|
||||
# bin
|
||||
# .. envvar:: flexlm__lmgrd_version [[[
|
||||
#
|
||||
# Specifies the version of ``lmgrd`` daemon.
|
||||
# Use to differentiate lmgrd on multiple versions in case of incompatibility with a vendor daemon binary.
|
||||
#
|
||||
# A symlink will be create to ``lmgrd`` daemon to have a simpler name.
|
||||
#
|
||||
flexlm__lmgrd_version: '11.14.0.1'
|
||||
flexlm__lmgrd_source: 'usr/local/bin/lmgrd'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: flexlm__lmgrd_path [[[
|
||||
#
|
||||
# Path to store ``lmgrd`` daemon.
|
||||
flexlm__lmgrd_path: '/usr/local/bin/lmgrd'
|
||||
flexlm__lmutil_source: 'usr/local/bin/lmutil'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: flexlm__lmgrd_source [[[
|
||||
#
|
||||
# Path where ``lmgrd`` daemon source is stored.
|
||||
flexlm__lmgrd_source: 'usr/local/bin/lmgrd'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: flexlm__lmutil_path [[[
|
||||
#
|
||||
# Path to store ``lmutil`` daemon.
|
||||
flexlm__lmutil_path: '/usr/local/bin/lmutil'
|
||||
|
||||
# user
|
||||
# ]]]
|
||||
# .. envvar:: flexlm__lmutil_source [[[
|
||||
#
|
||||
# Path where ``lmutil`` daemon source is stored.
|
||||
flexlm__lmutil_source: 'usr/local/bin/lmutil'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: flexlm__user_name [[[
|
||||
#
|
||||
# The user under which FlexLM daemons are running during normal operation.
|
||||
flexlm__user_name: 'flexlm'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: apache__service_name [[[
|
||||
#
|
||||
# The name of the Apache service.
|
||||
flexlm__service_manage: True
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
|
||||
# service
|
||||
flexlm__service_enabled: True
|
||||
flexlm__service_unit_content: 'etc/systemd/system/flexlm.service.j2'
|
||||
|
||||
|
||||
# Lists to manage vendor daemon and licence files.
|
||||
# flexlm_licences:
|
||||
# - name: matlab
|
||||
|
@ -49,9 +94,4 @@ flexlm__user_name: 'flexlm'
|
|||
# ports: [ '27000', '33188' ] # not used right now
|
||||
flexlm__licences: []
|
||||
|
||||
# service
|
||||
flexlm__service_manage: True
|
||||
flexlm__service_enabled: True
|
||||
flexlm__service_unit_content: 'etc/systemd/system/flexlm.service.j2'
|
||||
|
||||
# ]]]
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
- name: restart flexlm services
|
||||
service:
|
||||
name: '{{ "flexlm-" + item.name }}'
|
||||
state: restarted
|
||||
state: '{{ "restarted" if (flexlm__deploy_state == "present" and (item.service | d(True)) else "stopped" }}'
|
||||
with_flattened:
|
||||
- '{{ flexlm__licences }}'
|
||||
when: ( flexlm__service_manage and
|
||||
( item.service | d(True) ))
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
createhome: False
|
||||
system: True
|
||||
|
||||
# bin {{{
|
||||
# lmgrd and lmutil binaries [[[1
|
||||
- name: Add lmgrd bin
|
||||
copy:
|
||||
src: '{{ flexlm__lmgrd_source + "." + flexlm__lmgrd_version }}'
|
||||
|
@ -44,9 +44,7 @@
|
|||
group: '{{ flexlm__user_name }}'
|
||||
mode: 0755
|
||||
|
||||
# }}}
|
||||
|
||||
# VENDOR and licence {{{
|
||||
# VENDOR and licence [[[1
|
||||
- name: Add VENDOR DAEMON
|
||||
copy:
|
||||
src: '{{ item.bin_src }}'
|
||||
|
@ -71,9 +69,7 @@
|
|||
when: (item.lic_src|d())
|
||||
notify: ['restart flexlm services']
|
||||
|
||||
# }}}
|
||||
|
||||
# service {{{
|
||||
# Manage services [[[1
|
||||
|
||||
- name: Add systemd unit
|
||||
template:
|
||||
|
@ -82,27 +78,34 @@
|
|||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
register: flexlm__register_systemd_service
|
||||
register: flexlm__register_service
|
||||
notify: ['restart flexlm services']
|
||||
with_flattened:
|
||||
- '{{ flexlm__licences }}'
|
||||
when: ( flexlm__service_manage and
|
||||
when: ( (flexlm__deploy_state == "present") and
|
||||
( item.service | d(True) ))
|
||||
|
||||
- name: Purge systemd unit
|
||||
file:
|
||||
dest: '{{ "/etc/systemd/system/flexlm-" + item.name + ".service" }}'
|
||||
state: absent
|
||||
register: flexlm__register_service
|
||||
notify: ['restart flexlm services']
|
||||
with_flattened:
|
||||
- '{{ flexlm__licences }}'
|
||||
when: ( (flexlm__deploy_state == "absent") or
|
||||
not ( item.service | d(True) | bool ))
|
||||
|
||||
- name: Reload systemd daemons
|
||||
command: systemctl daemon-reload
|
||||
notify: ['restart flexlm services']
|
||||
when: (flexlm__service_manage and
|
||||
flexlm__register_systemd_service|changed)
|
||||
when: ( flexlm__register_service|changed )
|
||||
|
||||
- name: SERVICE manage services
|
||||
- name: Manage services
|
||||
service:
|
||||
name: '{{ "flexlm-" + item.name }}'
|
||||
state: started
|
||||
enabled: '{{ flexlm__service_enabled }}'
|
||||
state: '{{ "started" if (flexlm__deploy_state == "present" and (item.service | d(True)) else "stopped" }}'
|
||||
enabled: '{{ item.service | d(True) | bool }}'
|
||||
with_flattened:
|
||||
- '{{ flexlm__licences }}'
|
||||
when: ( flexlm__service_manage and
|
||||
( item.service | d(True) ))
|
||||
|
||||
# }}}
|
||||
|
|
Loading…
Reference in New Issue