diff --git a/CHANGELOG.md b/CHANGELOG.md index 9433eda..7775875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,4 @@ * Copy `lmgrd` and `lmutil` binaries. * Ensure to have a symlink for `lmgrd` to it's last version. * Create a specific user to launch `lmgrd`. +* Set up a systemd service. diff --git a/README.md b/README.md index fc82c65..782e8ae 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ A role to manage Flexlm daemon. * **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__service_manage** : If Licence Manager service should be managed with this role [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`]. ## Example Playbook @@ -37,8 +43,9 @@ A role to manage Flexlm daemon. ## Configuration This role will : -* Copy the `lmgrd` and `lmutil` binaries to the node. +* 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]. The `lmgrd` and `lmutil` binaries comes from [Mathworks][mathworks download url] in version **flexlm__lmgrd_version**. @@ -66,3 +73,4 @@ Jérémy Gardais [wtfpl website]: http://www.wtfpl.net/about/ [ipr website]: https://ipr.univ-rennes1.fr/ [mathworks download url]: https://fr.mathworks.com/support/install/license_manager_files.html +[kalebo instruction flexlm systemd]: https://gist.github.com/kalebo/fd39edb6c6e4ebed41f7eab2d9925ebc diff --git a/defaults/main.yml b/defaults/main.yml index bb765e9..c585893 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,3 +15,12 @@ flexlm__lmutil_path: '/usr/local/bin/lmutil' # user flexlm__user_name: 'flexlm' + +# service +flexlm__service_manage: 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' +flexlm__service_unit_content: 'etc/systemd/system/flexlm.service.j2' + diff --git a/tasks/main.yml b/tasks/main.yml index 63552f6..1d8c703 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -47,3 +47,16 @@ # }}} +# service {{{ + +- name: '{{ flexlm__service_name }} systemd service unit' + template: + src: '{{ flexlm__service_unit_content }}' + dest: '{{ flexlm__service_unit_path }}' + owner: 'root' + group: 'root' + mode: '0644' + register: flexlm__register_systemd_service + when: flexlm__service_manage + +# }}} diff --git a/templates/etc/systemd/system/flexlm.service.j2 b/templates/etc/systemd/system/flexlm.service.j2 new file mode 100644 index 0000000..a52dfe5 --- /dev/null +++ b/templates/etc/systemd/system/flexlm.service.j2 @@ -0,0 +1,16 @@ +# {{ ansible_managed }} +[Unit] +Description={{ flexlm__service_description }} +After=network.target + +[Service] +Type=simple +User=flexlm +WorkingDirectory={{ flexlm__service_working_directory }} +ExecStart={{ flexlm__lmgrd_path }} -z -c licence.lic +SuccessExitStatus=15 +Restart=always +RestartSec=30 + +[Install] +WantedBy=multi-user.target