Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

14 changed files with 93 additions and 326 deletions

View File

@ -1,65 +1,3 @@
## 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 ## v1.0

View File

@ -4,56 +4,53 @@
2. [Role Variables](#role-variables) 2. [Role Variables](#role-variables)
3. [Example Playbook](#example-playbook) 3. [Example Playbook](#example-playbook)
4. [Configuration](#configuration) 4. [Configuration](#configuration)
5. [Known Issues](#known-issues) 5. [Development](#development)
6. [Development](#development) 6. [License](#license)
7. [License](#license) 7. [Author Information](#author-information)
8. [Author Information](#author-information)
## Overview ## Overview
A role to manage Flexlm daemon and licence/binaries files. A role to manage Flexlm daemon.
## Role Variables ## Role Variables
* **flexlm__required_packages**: List of required packages requested as 'flexlm' dependencies [default: `[]`] * **flexlm__packages_state**: State of package(s) [default: `present`].
* **flexlm__deploy_state**: The desired state this role should achieve. [default: `present`]. * **flexlm__packages_manage**: If package(s) should be managed with this role [default: `True`].
* **flexlm__lmgrd_version**: Version of `lmgrd` to use [default: `11.18.1`]. * **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__lmgrd_source**: Source of the `lmgrd` bin to send [default: `usr/local/bin/lmgrd`]. * **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__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_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__lmutil_path**: The place to store `lmutil` bin [default: `/usr/local/bin/lmutil`].
* **flexlm__user_name**: Username used to launch `lmgrd` [default: `flexlm`]. * **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__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 ## Example Playbook
* Manage Flexlm to provide Intel Fortran (without binaries): * Manage Flexlm with defaults vars:
``` yaml ``` yml
- hosts: intel-lm - hosts: serverXYZ
roles: roles:
- role: ipr-cnrs.flexlm - 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 Matlab Licence and vendor daemon binaries: * Manage Flexlm to provide Intel Fortran:
```yaml ``` yml
- hosts: matlab-lm - hosts: intel-lm
roles: croles:
- role: ipr-cnrs.flexlm - role: ipr-cnrs.flexlm
flexlm__licences: flexlm__service_working_directory: '/opt/intel/bin'
- name: matlab flexlm__licence_file: '/opt/intel/etc/license.lic'
description: 'flexlm Licence Manager for Matlab' flexlm__service_description: 'Licence Manager for Intel Fortran'
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 ## Configuration
@ -61,18 +58,10 @@ A role to manage Flexlm daemon and licence/binaries files.
This role will: This role will:
* Copy the `lmgrd` and `lmutil` binaries to the client. * Copy the `lmgrd` and `lmutil` binaries to the client.
* Create a specific user to launch daemon. * Create a specific user to launch daemon.
* Set up a systemd service (flexlm-item.name). [Thanks to Kalebo instructions][kalebo instruction flexlm systemd]. * Set up a systemd service. [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**. 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 ## 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… 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…
@ -92,7 +81,7 @@ Jérémy Gardais
* [IPR][ipr website] (Institut de Physique de Rennes) * [IPR][ipr website] (Institut de Physique de Rennes)
[gogs to github hook]: https://stackoverflow.com/a/21998477 [gogs to github hook]: https://stackoverflow.com/a/21998477
[flexlm source]: https://git.ipr.univ-rennes.fr/cellinfo/ansible.flexlm [flexlm source]: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.flexlm
[flexlm github]: https://github.com/ipr-cnrs/flexlm [flexlm github]: https://github.com/ipr-cnrs/flexlm
[wtfpl website]: http://www.wtfpl.net/about/ [wtfpl website]: http://www.wtfpl.net/about/
[ipr website]: https://ipr.univ-rennes1.fr/ [ipr website]: https://ipr.univ-rennes1.fr/

View File

@ -1,126 +1,30 @@
--- ---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker # defaults file for flexlm
# ipr-cnrs.flexlm default variables [[[ # packages
# ====================================== flexlm__packages_state: 'present'
flexlm__packages_manage: True
flexlm__dependent_packages: [ 'lsb-core', 'unzip' ]
# Packages and installation [[[ # bin
# ----------------------------- flexlm__lmgrd_version: '11.14.0.1'
# .. 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'
# ]]]
# .. envvar:: flexlm__lmgrd_source [[[
#
# Path where ``lmgrd`` daemon source is stored.
flexlm__lmgrd_source: 'usr/local/bin/lmgrd' flexlm__lmgrd_source: 'usr/local/bin/lmgrd'
flexlm__lmgrd_path: '/usr/local/bin/lmgrd'
# ]]] flexlm__lmutil_source: 'usr/local/bin/lmutil'
# .. envvar:: flexlm__lmutil_path [[[
#
# Path to store ``lmutil`` daemon.
flexlm__lmutil_path: '/usr/local/bin/lmutil' 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' flexlm__user_name: 'flexlm'
# ]]] # licence
# .. envvar:: apache__service_name [[[ flexlm__licence_file: '/opt/flexlm/VENDOR/licence.lic'
#
# The name of the Apache service.
flexlm__service_manage: True
# ]]] # service
# .. envvar:: flexlm__service_unit_content [[[ flexlm__service_manage: True
# flexlm__service_enabled: True
# Template used to provide systemd unit for ``flexlm-...`` services. 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'
flexlm__service_unit_content: 'etc/systemd/system/flexlm.service.j2' 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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +1,5 @@
--- ---
# handlers file for flexlm # handlers file for flexlm
- name: restart flexlm services - name: restart flexlm service
service: service: name={{ flexlm__service_name }} state=restarted
name: '{{ "flexlm-" + item.name }}' when: flexlm__service_manage
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,19 +1,14 @@
---
dependencies: []
galaxy_info: galaxy_info:
author: "Jérémy Gardais" author: "Jérémy Gardais"
description: "Manage FlexLM daemon" description: "Manage FlexLM daemon"
license: WTFPL license: WTFPL
company: IPR company: IPR
issue_tracker_url: https://git.ipr.univ-rennes.fr/cellinfo/ansible.flexlm/issues issue_tracker_url: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.flexlm/issues
min_ansible_version: 2.9 min_ansible_version: 2.4
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- bullseye - stretch
- buster
galaxy_tags: galaxy_tags:
- system - system
- flexlm - flexlm

View File

@ -1,56 +1,28 @@
--- ---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# tasks file for flexlm # tasks file for flexlm
# Load vars [[[1 # package {{{
- name: Load specific OS vars - name: INSTALL FlexLM packages
ansible.builtin.include_vars: "{{ item }}" package:
with_first_found: name: '{{ item }}'
- files: state: '{{ flexlm__packages_state }}'
- "{{ 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 install_recommends: False
register: flexlm_pkg_result with_flattened:
until: flexlm_pkg_result is success - '{{ flexlm__dependent_packages }}'
when: flexlm__packages_manage
# }}}
# user # user
- name: Create flexlm user - name: Create flexlm user
ansible.builtin.user: user:
name: '{{ flexlm__user_name }}' name: '{{ flexlm__user_name }}'
createhome: False createhome: False
system: True system: True
# Create a symlink for /tmp [[[1 # bin {{{
- 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 - name: Add lmgrd bin
ansible.builtin.copy: copy:
src: '{{ flexlm__lmgrd_source + "." + flexlm__lmgrd_version }}' src: '{{ flexlm__lmgrd_source + "." + flexlm__lmgrd_version }}'
dest: '{{ flexlm__lmgrd_path + "." + flexlm__lmgrd_version }}' dest: '{{ flexlm__lmgrd_path + "." + flexlm__lmgrd_version }}'
owner: '{{ flexlm__user_name }}' owner: '{{ flexlm__user_name }}'
@ -58,7 +30,7 @@
mode: 0755 mode: 0755
- name: Link to the last version of lmgrd - name: Link to the last version of lmgrd
ansible.builtin.file: file:
src: '{{ flexlm__lmgrd_path + "." + flexlm__lmgrd_version }}' src: '{{ flexlm__lmgrd_path + "." + flexlm__lmgrd_version }}'
dest: '{{ flexlm__lmgrd_path }}' dest: '{{ flexlm__lmgrd_path }}'
owner: '{{ flexlm__user_name }}' owner: '{{ flexlm__user_name }}'
@ -66,57 +38,39 @@
state: link state: link
- name: Add lmutil bin - name: Add lmutil bin
ansible.builtin.copy: copy:
src: '{{ flexlm__lmutil_source }}' src: '{{ flexlm__lmutil_source }}'
dest: '{{ flexlm__lmutil_path }}' dest: '{{ flexlm__lmutil_path }}'
owner: '{{ flexlm__user_name }}' owner: '{{ flexlm__user_name }}'
group: '{{ flexlm__user_name }}' group: '{{ flexlm__user_name }}'
mode: 0755 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']
- name: Add licence file # service {{{
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']
# Manage services [[[1 - name: SERVICE '{{ flexlm__service_name }}' systemd unit
template:
- name: Add systemd unit
ansible.builtin.template:
src: '{{ flexlm__service_unit_content }}' src: '{{ flexlm__service_unit_content }}'
dest: '{{ "/etc/systemd/system/flexlm-" + item.name + ".service" }}' dest: '{{ flexlm__service_unit_path }}'
owner: 'root' owner: 'root'
group: 'root' group: 'root'
mode: '0644' mode: '0644'
with_flattened: register: flexlm__register_systemd_service
- '{{ flexlm__licences }}' notify: ['restart flexlm service']
when: ( (flexlm__deploy_state == "present") and when: flexlm__service_manage
( item.service | d(True) ))
notify: ['systemd daemon reload', 'restart flexlm services']
- name: Manage flexlm services - name: Reload systemd daemons
ansible.builtin.service: command: systemctl daemon-reload
name: '{{ "flexlm-" + item.name }}' notify: ['restart flexlm service']
state: '{{ "started" if (flexlm__deploy_state == "present" and (item.service | d(True) | bool)) else "stopped" }}' when: (flexlm__service_manage and
enabled: '{{ item.service | d(True) | bool }}' flexlm__register_systemd_service|changed)
with_flattened:
- '{{ flexlm__licences }}' - name: SERVICE manage '{{ flexlm__service_name }}'
service:
name: '{{ flexlm__service_name }}'
state: started
enabled: '{{ flexlm__service_enabled }}'
when: flexlm__service_manage
# }}}

View File

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

View File

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