Skip to content

Commit 4cfd2da

Browse files
committed
Ansible role for installing ThinLinc servers
This is a rework of the older Ansible code to install the ThinLinc Server. This comes in the more usable role form, rather than the old playbook.
0 parents  commit 4cfd2da

20 files changed

Lines changed: 1094 additions & 0 deletions

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
ThinLinc Server
2+
===============
3+
4+
This role takes care of installing, configuring and starting the
5+
ThinLinc Server software.
6+
7+
8+
License
9+
-------
10+
11+
GPLv3. (See LICENSE)
12+
13+
14+
Contributions
15+
-------------
16+
17+
Pull requests and issues are welcome.
18+
19+
20+
Requirements
21+
------------
22+
23+
- [ThinLinc Server requirements](https://www.cendio.com/resources/docs/tag/requirements_server.html) - but see `thinlinc-autoinstall-dependencies` below.
24+
25+
26+
Role Variables
27+
--------------
28+
29+
```yaml
30+
thinlinc_accept_eula: "no"
31+
```
32+
33+
By changing this to "yes", you agree to the terms specified in the
34+
ThinLinc End User License Agreement. NOTE: Setting this to yes is a
35+
requirement for installing and using ThinLinc.
36+
37+
```yaml
38+
thinlinc_version: "4.9.0"
39+
thinlinc_build: "5775"
40+
thinlinc_server_bundle_file: "tl-4.9.0-server.zip"
41+
```
42+
43+
ThinLinc version, build number and server bundle names.
44+
45+
```yaml
46+
thinlinc_autoinstall_dependencies: "yes"
47+
```
48+
49+
When set to "yes", this will automatically install any required
50+
dependencies along with the ThinLinc software. If set to "no", the
51+
role assumes that you will take care of it.
52+
53+
```yaml
54+
thinlinc_email: "root@localhost"
55+
```
56+
57+
Administrative email address to receive license warnings.
58+
59+
```yaml
60+
thinlinc_printers: "yes"
61+
```
62+
63+
Whether to install the optional CUPS printer queues for ThinLinc.
64+
65+
```yaml
66+
thinlinc_webadm_password: "$6$7cc31a35e02e55ec$hm.1MsloeBJqNKljx9RH88Z/eRKZCka5ZlabkZGj0nYXh0IaxaiYucsDD.fGJ5sNPthWf63pXkCn9Nu0ua2Ye1"
67+
```
68+
69+
ThinLinc Web Administration password. This default password is
70+
"thinlinc". Generate new hashes with /opt/thinlinc/sbin/tl-gen-auth.
71+
72+
73+
Dependencies
74+
------------
75+
76+
No external Ansible dependencies.
77+
78+
79+
Example Playbook
80+
----------------
81+
82+
Example inventory file:
83+
84+
```yaml
85+
[thinlinc-masters]
86+
tl-master-01.example.com
87+
88+
[thinlinc-agents]
89+
tl-agent-01.example.com
90+
tl-agent-02.example.com
91+
tl-agent-03.example.com
92+
93+
[thinlinc-servers:children]
94+
thinlinc-masters
95+
thinlinc-agents
96+
```
97+
98+
Example playbook:
99+
100+
```yaml
101+
- hosts: thinlinc-servers
102+
roles:
103+
- { role: thinlinc-server, thinlinc_accept_eula: "yes" }
104+
```

defaults/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
# defaults file for thinlinc-server
3+
4+
thinlinc_accept_eula: "no"
5+
6+
thinlinc_version: "4.9.0"
7+
thinlinc_build: "5775"
8+
thinlinc_server_bundle: "tl-4.9.0-server.zip"
9+
10+
thinlinc_autoinstall_dependencies: "yes"
11+
12+
thinlinc_email: "root@localhost"
13+
thinlinc_printers: "yes"
14+
15+
# ThinLinc Web Administration password. This default password is
16+
# "thinlinc". Generate new hashes with /opt/thinlinc/sbin/tl-gen-auth.
17+
thinlinc_webadm_password: "$6$7cc31a35e02e55ec$hm.1MsloeBJqNKljx9RH88Z/eRKZCka5ZlabkZGj0nYXh0IaxaiYucsDD.fGJ5sNPthWf63pXkCn9Nu0ua2Ye1"
18+
19+
# What should tl-setup do with existing configuration?
20+
# - old: leave old config as-is
21+
# - new: overwrite all local changes with new defaults
22+
# - parameters: auto-migrate old to new configuration
23+
thinlinc_tlsetup_migrate_conf: "old"

handlers/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# handlers file for thinlinc-server
3+
- name: restart vsmagent
4+
service: name=vsmagent state=restarted
5+
6+
- name: restart vsmserver
7+
service: name=vsmserver state=restarted
8+
9+
- name: run tl-setup
10+
command: /opt/thinlinc/sbin/tl-setup -a "/root/thinlinc-setup.answers"

library/tlconfig.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/python
2+
#
3+
# Ansible interface to tl-config
4+
#
5+
# Copyright 2016- Karl Mikaelsson <derfian@cendio.se> for Cendio AB
6+
7+
import subprocess
8+
from ansible.module_utils.basic import AnsibleModule
9+
10+
DOCUMENTATION = '''
11+
---
12+
module: tlconfig
13+
short_description: Ansible interface to tl-config
14+
author: "Karl Mikaelsson, @derfian"
15+
requirements:
16+
- ThinLinc Server
17+
18+
'''
19+
20+
EXAMPLES = '''
21+
- tlconfig: param=/vsmserver/HA/enabled value=1
22+
'''
23+
24+
RETURN = '''
25+
changed:
26+
type: bool
27+
param:
28+
type: str
29+
'''
30+
31+
TLCONFIG = "/opt/thinlinc/bin/tl-config"
32+
33+
def getvalue(param):
34+
tlproc = subprocess.Popen([TLCONFIG, "%s" % param], stdout=subprocess.PIPE)
35+
stdout, _ = tlproc.communicate()
36+
return stdout.rstrip()
37+
38+
def setvalue(param, value):
39+
tlproc = subprocess.Popen([TLCONFIG, "%s=%s" % (param, value)])
40+
return tlproc.wait()
41+
42+
def main():
43+
changed = False
44+
45+
module = AnsibleModule(argument_spec=dict(param=dict(required=True, type='str'),
46+
value=dict(required=True)),
47+
supports_check_mode=True)
48+
49+
if module.check_mode:
50+
module.exit_json(changed=module.params['value'] != getvalue(module.params['param']))
51+
52+
if len(module.params['param']) == 0:
53+
module.fail_json(msg="Param can't be empty")
54+
55+
if len(module.params['value']) == 0:
56+
module.fail_json(msg="Value can't be empty")
57+
58+
if getvalue(module.params['param']) != module.params['value']:
59+
ret = setvalue(module.params['param'], module.params['value'])
60+
61+
if ret is not 0:
62+
msg = "Failed setting %s: tl-config returned %d" % (module.params['param'], ret)
63+
module.fail_json(msg=msg)
64+
changed = True
65+
66+
module.exit_json(changed=changed,
67+
param=module.params['param'],
68+
value=module.params['value'])
69+
70+
if __name__ == '__main__':
71+
main()

meta/main.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
galaxy_info:
2+
author: Karl Mikaelsson
3+
description: your description
4+
company: Cendio AB
5+
license: GPLv3
6+
7+
min_ansible_version: 2.0
8+
# min_ansible_container_version:
9+
# github_branch:
10+
11+
platforms:
12+
- name: EL
13+
versions:
14+
- 7
15+
- name: SLES
16+
versions:
17+
- 12
18+
- 12SP1
19+
- name: Debian
20+
versions:
21+
- stretch
22+
- name: Ubuntu
23+
versions:
24+
- bionic
25+
26+
27+
galaxy_tags: []
28+
29+
dependencies: []

tasks/check_installed_deb.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Checking whether ThinLinc is installed
3+
command: "/usr/bin/dpkg-query --list thinlinc-vsm"
4+
args:
5+
warn: False
6+
register: thinlinc_packages_installed
7+
failed_when: ( thinlinc_packages_installed.rc not in [0, 1] )
8+
changed_when: False
9+
# ignore_errors: yes

tasks/check_installed_rpm.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
- name: Checking whether ThinLinc is installed
4+
command: "rpm -q thinlinc-vsm-{{ thinlinc_version }}-{{ thinlinc_build }}"
5+
args:
6+
warn: False
7+
register: thinlinc_packages_installed
8+
failed_when: ( thinlinc_packages_installed.rc not in [0, 1] )
9+
changed_when: False
10+
11+

tasks/install-thinlinc-debian.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# Because of circular dependencies, we need to install all packages at
3+
# once. I can't get the apt provider to install multiple local
4+
# packages all at once though. :/
5+
#
6+
# apt: deb="{{ item }}" state=present
7+
# with_items: "{{ thinlinc_packages }}"
8+
9+
- name: Install ThinLinc Software
10+
command: "/usr/bin/dpkg --install {{ ' '.join(thinlinc_packages) }}"
11+
notify: run tl-setup

tasks/install-thinlinc-rhel.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Install ThinLinc Software
3+
yum: name="{{ item }}" state=present
4+
with_items: "{{ thinlinc_packages }}"
5+
notify: run tl-setup

0 commit comments

Comments
 (0)