summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Harbott <j.harbott@x-ion.de>2017-12-11 16:06:22 +0000
committerColleen Murphy <colleen.murphy@suse.de>2018-08-09 20:56:27 +0200
commit05b1414b9b40b8b6cd325ae8df7e00954fbfe695 (patch)
tree574a7331d7ed384b458c19356f1219a5514743e2
parent785e18decb8339ecb591a1acc8352036316bd8e9 (diff)
Update ethercalc to work with Ubuntu Xenial
- Set up service via systemd instead of upstart. - defupalt to using nodejs v6.x because of library issues. - upstream nodejs puppet knows how to do legacy symlinks on required platforms. Depends-On: I2355cf58c899bf5f78173b2ed9da26548a9592d0 Depends-On: Ia7966fb9578d0d79f3a7f9480e3a956555737dc8 Change-Id: Ia3f4d3bbacbbe1a42a33a4f934173fb54a582a8e
Notes
Notes (review): Code-Review+2: Colleen Murphy <colleen@gazlene.net> Code-Review+2: Ian Wienand <iwienand@redhat.com> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 10 Aug 2018 20:11:35 +0000 Reviewed-on: https://review.openstack.org/527144 Project: openstack-infra/puppet-ethercalc Branch: refs/heads/master
-rw-r--r--manifests/init.pp168
-rw-r--r--metadata.json2
-rw-r--r--templates/ethercalc.service.erb15
3 files changed, 127 insertions, 58 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 815a16d..48484ea 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -15,12 +15,41 @@ class ethercalc (
15 $base_log_dir = '/var/log', 15 $base_log_dir = '/var/log',
16 $ethercalc_user = 'ethercalc', 16 $ethercalc_user = 'ethercalc',
17 $ethercalc_version= '0.20161220.1', 17 $ethercalc_version= '0.20161220.1',
18 # If set to system will install system package. 18 # If set to system will install system package, otherwise
19 $nodejs_version = 'node_4.x', 19 # we try to choose one based on the host platform
20 $nodejs_version = undef,
20) { 21) {
21 22
22 $path = '/usr/local/bin:/usr/bin:/bin' 23 $path = '/usr/local/bin:/usr/bin:/bin'
23 24
25 # For trusty default to upstart, node 4.x. For Xenial onwards use
26 # node 6.x for updated dependencies and the default systemd service
27 # file
28 case $::operatingsystem {
29 'Ubuntu': {
30 if $::operatingsystemrelease <= '14.04' {
31 $use_upstart = true
32 if ! $nodejs_version {
33 $use_nodejs_version = '4.x'
34 }
35 }
36 else {
37 if ! $nodejs_version {
38 $use_nodejs_version = '6.x'
39 }
40 }
41 }
42 default: {
43 # TODO(ianw) -- not sure this is a sane default, but it's the
44 # way it was...
45 if ! $nodejs_version {
46 $use_nodejs_version = '4.x'
47 } else {
48 $use_nodejs_version = $nodejs_version
49 }
50 }
51 }
52
24 group { $ethercalc_user: 53 group { $ethercalc_user:
25 ensure => present, 54 ensure => present,
26 } 55 }
@@ -46,11 +75,16 @@ class ethercalc (
46 } 75 }
47 } 76 }
48 77
78 file { "${base_log_dir}/${ethercalc_user}":
79 ensure => directory,
80 owner => $ethercalc_user,
81 }
82
49 anchor { 'nodejs-package-install': } 83 anchor { 'nodejs-package-install': }
50 84
51 if ($nodejs_version != 'system') { 85 if ($use_nodejs_version != 'system') {
52 class { '::nodejs': 86 class { '::nodejs':
53 repo_url_suffix => $nodejs_version, 87 repo_url_suffix => $use_nodejs_version,
54 before => Anchor['nodejs-package-install'], 88 before => Anchor['nodejs-package-install'],
55 } 89 }
56 } else { 90 } else {
@@ -60,70 +94,90 @@ class ethercalc (
60 } 94 }
61 } 95 }
62 96
63 file { '/usr/local/bin/node':
64 ensure => link,
65 target => '/usr/bin/nodejs',
66 require => Anchor['nodejs-package-install'],
67 before => Anchor['nodejs-anchor'],
68 }
69
70 anchor { 'nodejs-anchor': }
71
72 exec { 'install-ethercalc': 97 exec { 'install-ethercalc':
73 command => "npm install ethercalc@${ethercalc_version}", 98 command => "npm install ethercalc@${ethercalc_version}",
74 unless => "npm ls | grep ethercalc@${ethercalc_version}", 99 unless => "npm ls | grep ethercalc@${ethercalc_version}",
75 path => $path, 100 path => $path,
76 cwd => $base_install_dir, 101 cwd => $base_install_dir,
77 require => Anchor['nodejs-anchor'], 102 require => Anchor['nodejs-package-install'],
78 } 103 }
79 104
80 file { '/etc/init/ethercalc.conf': 105 # TODO(ianw): remove this when trusty is dropped
81 ensure => present, 106 if $use_upstart {
82 content => template('ethercalc/upstart.erb'),
83 replace => true,
84 owner => 'root',
85 }
86 107
87 file { '/etc/init.d/ethercalc': 108 file { '/etc/init/ethercalc.conf':
88 ensure => link, 109 ensure => present,
89 target => '/lib/init/upstart-job', 110 content => template('ethercalc/upstart.erb'),
90 } 111 replace => true,
112 owner => 'root',
113 require => Exec['install-ethercalc'],
114 }
91 115
92 file { "${base_log_dir}/${ethercalc_user}": 116 file { '/etc/init.d/ethercalc':
93 ensure => directory, 117 ensure => link,
94 owner => $ethercalc_user, 118 target => '/lib/init/upstart-job'
95 } 119 }
96 120
97 service { 'ethercalc': 121 service { 'ethercalc':
98 ensure => running, 122 ensure => running,
99 enable => true, 123 enable => true,
100 require => File['/etc/init/ethercalc.conf'], 124 require => File['/etc/init/ethercalc.conf'],
101 } 125 }
102 126
103 include ::logrotate 127 include ::logrotate
104 logrotate::file { 'ethercalc_error': 128 logrotate::file { 'ethercalc_error':
105 log => "${base_log_dir}/${ethercalc_user}/error.log", 129 log => "${base_log_dir}/${ethercalc_user}/error.log",
106 options => [ 130 options => [
107 'compress', 131 'compress',
108 'copytruncate', 132 'copytruncate',
109 'missingok', 133 'missingok',
110 'rotate 7', 134 'rotate 7',
111 'daily', 135 'daily',
112 'notifempty', 136 'notifempty',
113 ], 137 ],
114 require => Service['ethercalc'], 138 require => Service['ethercalc'],
115 } 139 }
140
141 logrotate::file { 'ethercalc_access':
142 log => "${base_log_dir}/${ethercalc_user}/access.log",
143 options => [
144 'compress',
145 'copytruncate',
146 'missingok',
147 'rotate 7',
148 'daily',
149 'notifempty',
150 ],
151 require => Service['ethercalc'],
152 }
116 153
117 logrotate::file { 'ethercalc_access': 154 } else {
118 log => "${base_log_dir}/${ethercalc_user}/access.log", 155
119 options => [ 156 # Note logs go to syslog, can maybe change when
120 'compress', 157 # https://github.com/systemd/systemd/pull/7198 is available
121 'copytruncate', 158 file { '/etc/systemd/system/ethercalc.service':
122 'missingok', 159 ensure => present,
123 'rotate 7', 160 content => template('ethercalc/ethercalc.service.erb'),
124 'daily', 161 replace => true,
125 'notifempty', 162 owner => 'root',
126 ], 163 require => Exec['install-ethercalc'],
127 require => Service['ethercalc'], 164 }
165
166 # This is a hack to make sure that systemd is aware of the new service
167 # before we attempt to start it.
168 exec { 'ethercalc-systemd-daemon-reload':
169 command => '/bin/systemctl daemon-reload',
170 before => Service['ethercalc'],
171 subscribe => File['/etc/systemd/system/ethercalc.service'],
172 refreshonly => true,
173 }
174
175 service { 'ethercalc':
176 ensure => running,
177 enable => true,
178 require => File['/etc/systemd/system/ethercalc.service'],
179 }
128 } 180 }
181
182
129} 183}
diff --git a/metadata.json b/metadata.json
index 7611a3a..c70d65b 100644
--- a/metadata.json
+++ b/metadata.json
@@ -10,6 +10,6 @@
10 "dependencies": [ 10 "dependencies": [
11 {"name":"openstackinfra/httpd"}, 11 {"name":"openstackinfra/httpd"},
12 {"name":"openstackinfra/redis"}, 12 {"name":"openstackinfra/redis"},
13 {"name":"voxpupuli/nodejs"} 13 {"name":"puppet/nodejs"}
14 ] 14 ]
15} 15}
diff --git a/templates/ethercalc.service.erb b/templates/ethercalc.service.erb
new file mode 100644
index 0000000..d3e7540
--- /dev/null
+++ b/templates/ethercalc.service.erb
@@ -0,0 +1,15 @@
1[Unit]
2Description=ethercalc (real-time collaborative spreadsheet editing)
3After=syslog.target network.target
4
5[Service]
6Type=simple
7User=<%= @ethercalc_user %>
8Group=<%= @ethercalc_user %>
9ExecStart=/bin/bash <%= @base_install_dir %>/node_modules/ethercalc/bin/run.sh
10LimitNOFILE=8192:16384
11StandardOutput=syslog
12StandardError=syslog
13
14[Install]
15WantedBy=multi-user.target