Compare commits

...

31 Commits

Author SHA1 Message Date
Jeremy Gardais 659b2b04ac
Update domain for git.ipr 2023-11-03 16:06:45 +01:00
Jeremy Gardais f71f77d10a
Prefix module with "ansible.builtin." 2023-01-24 11:40:23 +01:00
Jeremy Gardais edd21486f8
Use flatten to manage packages list 2023-01-24 11:34:35 +01:00
Jeremy Gardais c0a911d5df
Role works with Debian Bullseye 2022-03-24 17:12:57 +01:00
Jeremy Gardais c089beb8fe
Remove old 11.14.0 version of lmgrd 2022-03-24 16:50:11 +01:00
Jeremy Gardais 51adb58540
Upgrade lmgrd and lmutil daemon to version 11.18.1 2022-03-24 16:47:40 +01:00
Jeremy Gardais 8a8a9ddd72 Debian Buster support 2020-05-07 11:24:24 +02:00
Jeremy Gardais 1ee35d9ea4 Ensure lib64 ld-linux symlinks exists 2020-05-07 11:23:13 +02:00
Jeremy Gardais 424dc5d8ee Empty requirements packages by default 2020-05-06 17:20:14 +02:00
Jeremy Gardais 212ea834b5 Ensure to install requirements on Debian Stretch 2020-05-06 17:18:34 +02:00
Jeremy Gardais 46422ee402 Publish version 2.1.4 2019-10-08 10:22:20 +02:00
Jeremy Gardais 6952eeeb16 Upgrade lmgrd and lmutil binaries to 11.16.2.1 2019-10-08 10:16:04 +02:00
Jeremy Gardais bc33b60bda
Use to_nice_json to manage packages list 2019-02-27 11:49:10 +01:00
Jeremy Gardais 9c8c181e70
Fix E503 Task that run when changed should likely be handlers
Daemon_reload moved to handlers file.
2019-02-26 17:30:43 +01:00
Jeremy Gardais f85fd58bad
Fix E303 systemctl used in place of systemd module 2019-02-26 14:05:37 +01:00
Jeremy Gardais 67b3cbc635
Fix E405 Remote package tasks should have a retry 2019-02-26 14:00:11 +01:00
Jeremy Gardais fbb6814ce8
Set empty dependencies line to fix Galaxy warning 2018-08-06 15:25:43 +02:00
Jeremy Gardais c6e53f30d9
Fix some minor warnings from ansible-lint 2018-08-06 15:25:03 +02:00
Jeremy Gardais f7f230589b Create a symlink (/usr/tmp) to /tmp to avoid error
fix #2 .
2018-02-28 15:04:06 +01:00
Jeremy Gardais a8a6192cdc Add a missing ")" in the handler 2018-02-28 14:43:40 +01:00
Jeremy Gardais 940a2b9dc7 Add more informations about flexlm__licences var 2018-02-28 11:34:26 +01:00
Jeremy Gardais 2913b41c13 Don't purge unit file
Otherwise the service can't be stopped.
2018-02-28 11:01:06 +01:00
Jeremy Gardais d498ca502a Revert 4a51da3
Cause if a service is started|stopped manually, it can't come back in
the desired state.
2018-02-28 10:58:25 +01:00
Jeremy Gardais bff4d7a11f Allow to manage the RestartSec parameter of the unit 2018-02-27 16:07:27 +01:00
Jeremy Gardais 4a51da3a96 Integrate "Manage services" to the handler 2018-02-27 15:51:44 +01:00
Jeremy Gardais 6cb121a5ea Ensure to remove service management if deploy state is "absent" 2018-02-27 15:47:08 +01:00
Jeremy Gardais 394b2ecdb5 Set a var to manage the state of the deployment by this role 2018-02-27 14:06:20 +01:00
Jeremy Gardais 659dd36f2b Remove old var in documentation 2018-02-27 12:07:28 +01:00
Jeremy Gardais bc5ad21d32 Manage services for the lists var (flexlm__licences)
Also allow to manage several licences on a same host (close #1)
2018-02-27 12:06:01 +01:00
Jeremy Gardais 2b531de478 Add possibility to deserve licence file to the host 2018-02-27 09:41:54 +01:00
Jeremy Gardais b4b3631f29 Add a way to provide vendor daemon for licences 2018-02-27 08:32:20 +01:00
14 changed files with 326 additions and 93 deletions

View File

@ -1,3 +1,65 @@
## v2.3.2
### Fix
* Use flatten to manage packages list.
* Prefix module with "ansible.builtin.".
## v2.3.1
### Enhancements
* Works with Debian Bullseye.
## v2.3.0
### Enhancements
* Upgrade lmgrd and lmutil daemon to version 11.18.1.
* Remove old 11.14.0 version of lmgrd.
## v2.2.0
### Enhancements
* Ensure to install requirements on Debian Stretch.
* Empty requirements packages by default cause `lsb-compat` is no longer available on Debian Buster.
* Ensure lib64 ld-linux symlinks exists.
* Now works with Debian Buster.
## v2.1.4
### Enhancements
* Upgrade lmgrd and lmutil daemon to version 11.16.2.1.
## v2.1.3
### Enhancements
* Use to_nice_json to manage packages list.
## v2.1.2
* Fix E405 Remote package tasks should have a retry.
* Fix E303 systemctl used in place of systemd module.
* Fix E503 Tasks that run when changed should likely be handlers. Daemon_reload moved to handlers file.
## v2.1.1
### Fixes
* Fix some warnings from ansible-lint.
* Set empty dependencies line to fix Galaxy warning.
## v2.1
### Fixes
* Add a missing ")" in the handler.
* Create a symlink (/usr/tmp) to /tmp to avoid error (fix #2).
## v2.0
### Features
* Add a way to provide vendor daemon binaries and licence file.
* Manage services for the lists var (flexlm__licences).
* Allow to manage several licences on a same host (close #1).
* The **RestartSec** argument for the service can be set, cause some vendor daemon have a timewait greater than 60 seconds.
### Enhancements
* Set a var to manage the state of the deployment by this role.
* Ensure to stop and disable services if deploy state is "absent".
* Add more informations about flexlm__licences var.
## v1.0

View File

@ -4,53 +4,56 @@
2. [Role Variables](#role-variables)
3. [Example Playbook](#example-playbook)
4. [Configuration](#configuration)
5. [Development](#development)
6. [License](#license)
7. [Author Information](#author-information)
5. [Known Issues](#known-issues)
6. [Development](#development)
7. [License](#license)
8. [Author Information](#author-information)
## Overview
A role to manage Flexlm daemon.
A role to manage Flexlm daemon and licence/binaries files.
## Role Variables
* **flexlm__packages_state**: State of package(s) [default: `present`].
* **flexlm__packages_manage**: If package(s) should be managed with this role [default: `True`].
* **flexlm__dependent_packages**: List of additional packages requested as 'flexlm' dependencies [default: `lsb-core`, `unzip`]
* **flexlm__lmgrd_version**: Version of `lmgrd` to use [default: `11.14.0.1`].
* **flexlm__required_packages**: List of required packages requested as 'flexlm' dependencies [default: `[]`]
* **flexlm__deploy_state**: The desired state this role should achieve. [default: `present`].
* **flexlm__lmgrd_version**: Version of `lmgrd` to use [default: `11.18.1`].
* **flexlm__lmgrd_source**: Source of the `lmgrd` bin to send [default: `usr/local/bin/lmgrd`].
* **flexlm__lmgrd_path**: The place to store `lmgrd` bin [default: `/usr/local/bin/lmgrd`].
* **flexlm__lmutil_source**: Source of the `lmutil` bin to send [default: `usr/local/bin/lmutil`].
* **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__licence_file**: Licence file to deserve [default: `/opt/flexlm/VENDOR/licence.lic`].
* **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_name**: Service name [default: `flexlm`].
* **flexlm__service_description**: Description of the systemd unit [default: `flexlm Licence Manager`].
* **flexlm__service_working_directory**: Working directory of the systemd unit [default: `/opt/flexlm/VENDOR`].
* **flexlm__service_unit_path**: Systemd unit path [default: `/etc/systemd/system/{{ flexlm__service_name }}.service`].
* **flexlm__service_unit_content**: Template used to generate the previous file [default: `etc/systemd/system/flexlm.service.j2`].
* **flexlm__licences**: Lists to manage vendor daemon and licence files [default: `[]`].
## Example Playbook
* Manage Flexlm with defaults vars:
* Manage Flexlm to provide Intel Fortran (without binaries):
``` yml
- hosts: serverXYZ
``` yaml
- hosts: intel-lm
roles:
- role: ipr-cnrs.flexlm
flexlm__licences:
- name: intel
description: 'flexlm Licence Manager for Matlab'
bin_path: '/opt/intel/bin'
lic_path: '/opt/matlab/etc/licence.lic' # need to be a file
```
* Manage Flexlm to provide Intel Fortran:
* Manage Flexlm to provide Matlab Licence and vendor daemon binaries:
``` yml
- hosts: intel-lm
croles:
```yaml
- hosts: matlab-lm
roles:
- role: ipr-cnrs.flexlm
flexlm__service_working_directory: '/opt/intel/bin'
flexlm__licence_file: '/opt/intel/etc/license.lic'
flexlm__service_description: 'Licence Manager for Intel Fortran'
flexlm__licences:
- name: matlab
description: 'flexlm Licence Manager for Matlab'
bin_path: '/opt/matlab/bin'
bin_src: '{{ inventory_dir + "/../resources/service/matlab-lm/bin/" }}'
lic_path: '/opt/matlab/etc/licence.lic' # need to be a file
lic_src: '{{ inventory_dir + "/../resources/host/matlab-lm.domain/etc/licence.lic" }}' # need to be a file
```
## Configuration
@ -58,10 +61,18 @@ A role to manage Flexlm daemon.
This role will:
* Copy the `lmgrd` and `lmutil` binaries to the client.
* Create a specific user to launch daemon.
* Set up a systemd service. [Thanks to Kalebo instructions][kalebo instruction flexlm systemd].
* Set up a systemd service (flexlm-item.name). [Thanks to Kalebo instructions][kalebo instruction flexlm systemd].
* Copy vendor daemon binaries to the host if source is specified.
* Copy licence file to the host if source is specified.
* Create a symlink (/usr/tmp) to /tmp to avoid error.
* Create a symlinks to ld-linux librairies.
The `lmgrd` and `lmutil` binaries comes from [Mathworks][mathworks download url] in version **flexlm__lmgrd_version**.
## Known Issues
* If a value of one licence change in **flexlm__licences** var, all services will be restarted.
## Development
This source code comes from our [Gogs instance][flexlm source] and the [Github repo][flexlm github] exist just to be able to send the role to Ansible Galaxy…
@ -81,7 +92,7 @@ Jérémy Gardais
* [IPR][ipr website] (Institut de Physique de Rennes)
[gogs to github hook]: https://stackoverflow.com/a/21998477
[flexlm source]: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.flexlm
[flexlm source]: https://git.ipr.univ-rennes.fr/cellinfo/ansible.flexlm
[flexlm github]: https://github.com/ipr-cnrs/flexlm
[wtfpl website]: http://www.wtfpl.net/about/
[ipr website]: https://ipr.univ-rennes1.fr/

View File

@ -1,30 +1,126 @@
---
# defaults file for flexlm
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
# packages
flexlm__packages_state: 'present'
flexlm__packages_manage: True
flexlm__dependent_packages: [ 'lsb-core', 'unzip' ]
# ipr-cnrs.flexlm default variables [[[
# ======================================
# bin
flexlm__lmgrd_version: '11.14.0.1'
flexlm__lmgrd_source: 'usr/local/bin/lmgrd'
# Packages and installation [[[
# -----------------------------
# .. envvar:: flexlm__base_packages [[[
#
# List of base packages to install.
flexlm__required_packages: []
# ]]]
# .. envvar:: flexlm__deploy_state [[[
#
# What is the desired state which this role should achieve? Possible options:
#
# ``present``
# Default. Ensure that flexlm is installed and configured as requested.
#
# ``absent``
# Ensure that flexlm is uninstalled and it's configuration is removed.
#
flexlm__deploy_state: 'present'
# ]]]
# ]]]
# Server configuration [[[
# ------------------------
# .. 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.18.1'
# ]]]
# .. 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'
# licence
flexlm__licence_file: '/opt/flexlm/VENDOR/licence.lic'
# service
# ]]]
# .. envvar:: apache__service_name [[[
#
# The name of the Apache service.
flexlm__service_manage: True
flexlm__service_enabled: True
flexlm__service_name: 'flexlm'
flexlm__service_description: 'flexlm Licence Manager'
flexlm__service_working_directory: '/opt/flexlm/VENDOR'
flexlm__service_unit_path: '/etc/systemd/system/{{ flexlm__service_name }}.service'
# ]]]
# .. envvar:: flexlm__service_unit_content [[[
#
# Template used to provide systemd unit for ``flexlm-...`` services.
flexlm__service_unit_content: 'etc/systemd/system/flexlm.service.j2'
# ]]]
# ]]]
# Licence and Vendor bin [[[
# ------------------------
# .. envvar:: flexlm__licences [[[
#
# Lists to manage vendor daemon and licence files.
#
# ``item.name``
# Give a short name for the software licence. Avoid whitespace and special
# caracter cause this var will also be used to name the service.
# ``item.description``
# Optional. Here you can give a long description of the licence. Also used as
# service's description.
# ``item.bin_path``
# Optional. Specify asbolute path of the target directory on the remote host
# to store vendor daemon binaries. Also used as working directory for the service.
# [Default: ``/opt/item.name/bin``].
# ``bin_src``
# Optional. Path from your controller used as source directory to provide the
# vendor daemon directory on the host. Should be a directory and don't omit
# the final **/**.
# ``lic_path``
# Optional. Specify absolut path of the target licence file on the remote
# host. Also used as argument of the start command for the service.
# [Default: ``/opt/item.name/etc/licence.lic``].
# ``lic_src``
# Optional. Path from your controller used as source file to provide the licence
# file on the host. Should be a file, not a directory.
# ``service``
# Optional. If the service should be started and enabled.
# [Default: ``True``].
# ``timewait``
# Optional. The time (in second) to wait before trying to restart the service
# after an error. I recommend at least 60 seconds because some vendor daemon
# keep a connection active even few seconds after the stop.
# [Default: ``60``].
# ``ports``
# The list of ports used by this licence.
# Not used right now.
flexlm__licences: []
# ]]]
# ]]]

Binary file not shown.

Binary file not shown.

BIN
files/usr/local/bin/lmgrd.11.18.1 Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,13 @@
---
# handlers file for flexlm
- name: restart flexlm service
service: name={{ flexlm__service_name }} state=restarted
when: flexlm__service_manage
- name: restart flexlm services
service:
name: '{{ "flexlm-" + item.name }}'
state: '{{ "restarted" if (flexlm__deploy_state == "present" and (item.service | d(True) | bool)) else "stopped" }}'
enabled: '{{ item.service | d(True) | bool }}'
with_flattened:
- '{{ flexlm__licences }}'
- name: systemd daemon reload
systemd:
daemon_reload: True

View File

@ -1,14 +1,19 @@
---
dependencies: []
galaxy_info:
author: "Jérémy Gardais"
description: "Manage FlexLM daemon"
license: WTFPL
company: IPR
issue_tracker_url: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.flexlm/issues
min_ansible_version: 2.4
issue_tracker_url: https://git.ipr.univ-rennes.fr/cellinfo/ansible.flexlm/issues
min_ansible_version: 2.9
platforms:
- name: Debian
versions:
- stretch
- bullseye
- buster
galaxy_tags:
- system
- flexlm

View File

@ -1,28 +1,56 @@
---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# tasks file for flexlm
# package {{{
- name: INSTALL FlexLM packages
package:
name: '{{ item }}'
state: '{{ flexlm__packages_state }}'
install_recommends: False
with_flattened:
- '{{ flexlm__dependent_packages }}'
when: flexlm__packages_manage
# Load vars [[[1
- name: Load specific OS vars
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution_release }}.yml"
- "{{ ansible_distribution|lower }}.yml"
- "{{ ansible_os_family|lower }}.yml"
skip: true
# }}}
# Manage required system packages [[[1
- name: Ensure required packages are in there desired state
ansible.builtin.package:
name: '{{ flexlm__required_packages | flatten }}'
state: '{{ "present" if (flexlm__deploy_state == "present") else "absent" }}'
install_recommends: False
register: flexlm_pkg_result
until: flexlm_pkg_result is success
# user
- name: Create flexlm user
user:
ansible.builtin.user:
name: '{{ flexlm__user_name }}'
createhome: False
system: True
# bin {{{
# Create a symlink for /tmp [[[1
- name: Symlink /usr/tmp
ansible.builtin.file:
src: /tmp
dest: /usr/tmp
state: link
# Create a symlink for libs [[[1
- name: Symlinks to /lib64/ld-linux-x86-64.so.2
ansible.builtin.file:
src: /lib64/ld-linux-x86-64.so.2
dest: '{{ item }}'
state: link
with_items:
- /lib64/ld-lsb-x86-64.so.2
- /lib64/ld-lsb-x86-64.so.3
# lmgrd and lmutil binaries [[[1
- name: Add lmgrd bin
copy:
ansible.builtin.copy:
src: '{{ flexlm__lmgrd_source + "." + flexlm__lmgrd_version }}'
dest: '{{ flexlm__lmgrd_path + "." + flexlm__lmgrd_version }}'
owner: '{{ flexlm__user_name }}'
@ -30,7 +58,7 @@
mode: 0755
- name: Link to the last version of lmgrd
file:
ansible.builtin.file:
src: '{{ flexlm__lmgrd_path + "." + flexlm__lmgrd_version }}'
dest: '{{ flexlm__lmgrd_path }}'
owner: '{{ flexlm__user_name }}'
@ -38,39 +66,57 @@
state: link
- name: Add lmutil bin
copy:
ansible.builtin.copy:
src: '{{ flexlm__lmutil_source }}'
dest: '{{ flexlm__lmutil_path }}'
owner: '{{ flexlm__user_name }}'
group: '{{ flexlm__user_name }}'
mode: 0755
# }}}
# VENDOR and licence [[[1
- name: Add VENDOR DAEMON
ansible.builtin.copy:
src: '{{ item.bin_src }}'
dest: '{{ item.bin_path | d("/opt/" + item.name + "/bin") }}'
owner: '{{ flexlm__user_name }}'
group: '{{ flexlm__user_name }}'
mode: 0754
with_flattened:
- '{{ flexlm__licences }}'
when: (item.bin_src|d())
notify: ['restart flexlm services']
# service {{{
- name: Add licence file
ansible.builtin.copy:
src: '{{ (item.lic_src | dirname) + "/" }}' # Need a final "/"
dest: '{{ (item.lic_path | d("/opt/" + item.name + "/etc/licence.lic")) | dirname }}'
owner: '{{ flexlm__user_name }}'
group: '{{ flexlm__user_name }}'
mode: 0640
with_flattened:
- '{{ flexlm__licences }}'
when: (item.lic_src|d())
notify: ['restart flexlm services']
- name: SERVICE '{{ flexlm__service_name }}' systemd unit
template:
# Manage services [[[1
- name: Add systemd unit
ansible.builtin.template:
src: '{{ flexlm__service_unit_content }}'
dest: '{{ flexlm__service_unit_path }}'
dest: '{{ "/etc/systemd/system/flexlm-" + item.name + ".service" }}'
owner: 'root'
group: 'root'
mode: '0644'
register: flexlm__register_systemd_service
notify: ['restart flexlm service']
when: flexlm__service_manage
with_flattened:
- '{{ flexlm__licences }}'
when: ( (flexlm__deploy_state == "present") and
( item.service | d(True) ))
notify: ['systemd daemon reload', 'restart flexlm services']
- name: Reload systemd daemons
command: systemctl daemon-reload
notify: ['restart flexlm service']
when: (flexlm__service_manage and
flexlm__register_systemd_service|changed)
- name: SERVICE manage '{{ flexlm__service_name }}'
service:
name: '{{ flexlm__service_name }}'
state: started
enabled: '{{ flexlm__service_enabled }}'
when: flexlm__service_manage
# }}}
- name: Manage flexlm services
ansible.builtin.service:
name: '{{ "flexlm-" + item.name }}'
state: '{{ "started" if (flexlm__deploy_state == "present" and (item.service | d(True) | bool)) else "stopped" }}'
enabled: '{{ item.service | d(True) | bool }}'
with_flattened:
- '{{ flexlm__licences }}'

View File

@ -1,16 +1,16 @@
# {{ ansible_managed }}
[Unit]
Description={{ flexlm__service_description }}
Description={{ item.description | d("flexlm Licence Manager for " + item.name) }}
After=network.target
[Service]
Type=simple
User={{ flexlm__user_name }}
WorkingDirectory={{ flexlm__service_working_directory }}
ExecStart={{ flexlm__lmgrd_path }} -z -c {{ flexlm__licence_file }}
WorkingDirectory={{ item.bin_path | d("/opt/" + item.name + "/bin") }}
ExecStart={{ flexlm__lmgrd_path }} -z -c {{ item.lic_path | d("/opt/" + item.name + "/etc/licence.lic") }}
SuccessExitStatus=15
Restart=always
RestartSec=30
RestartSec={{ item.timewait | d(60) | int }}
[Install]
WantedBy=multi-user.target

5
vars/debian-stretch.yml Normal file
View File

@ -0,0 +1,5 @@
---
# Specific vars for Debian Stretch
flexlm__required_packages:
- 'lsb-compat'