@@ -10,16 +10,22 @@ export PLUGINS_COMMON_SOURCE_URL=$(ctx node properties plugins_common_module_sou
10
10
export SCRIPT_PLUGIN_SOURCE_URL=$( ctx node properties script_plugin_module_source_url)
11
11
export REST_SERVICE_SOURCE_URL=$( ctx node properties rest_service_module_source_url)
12
12
export AGENT_SOURCE_URL=$( ctx node properties agent_module_source_url)
13
+ export SSH_KEY_FILE=$( ctx node properties ssh_key_filename)
14
+ export AGENT_USER=$( ctx node properties agents_user)
13
15
14
16
# This will only be used if the management worker is not installed via an RPM
15
17
export CELERY_VERSION=" 3.1.17"
16
18
19
+ export MGMTWORKER_USER=' cloudifymgmtworker'
20
+ export MGMTWORKER_GROUP=' cloudifymgmtworker'
21
+ export MGMTWORKER_HOME=" /opt/mgmtworker"
22
+
17
23
# these must all be exported as part of the start operation. they will not persist, so we should use the new agent
18
24
# don't forget to change all localhosts to the relevant ips
19
- export MGMTWORKER_HOME=" /opt/mgmtworker"
20
25
export MGMTWORKER_VIRTUALENV_DIR=" ${MGMTWORKER_HOME} /env"
21
26
export CELERY_WORK_DIR=" ${MGMTWORKER_HOME} /work"
22
27
export CELERY_LOG_DIR=" /var/log/cloudify/mgmtworker"
28
+ export MGMTWORKER_RIEMANN_POLICY_DIR=" /opt/riemann"
23
29
24
30
# Set broker port for rabbit
25
31
export BROKER_PORT_SSL=" 5671"
@@ -28,6 +34,8 @@ export RABBITMQ_SSL_ENABLED="$(ctx -j node properties rabbitmq_ssl_enabled)"
28
34
export RABBITMQ_CERT_PUBLIC=" $( ctx node properties rabbitmq_cert_public) "
29
35
30
36
ctx instance runtime_properties rabbitmq_endpoint_ip " $( get_rabbitmq_endpoint_ip) "
37
+ ctx instance runtime_properties mgmtworker_user ${MGMTWORKER_USER}
38
+ ctx instance runtime_properties mgmtworker_group ${MGMTWORKER_GROUP}
31
39
32
40
# Fix possible injections in json of rabbit credentials
33
41
# See json.org for string spec
@@ -51,6 +59,12 @@ create_dir ${MGMTWORKER_HOME}/config
51
59
create_dir ${CELERY_LOG_DIR}
52
60
create_dir ${CELERY_WORK_DIR}
53
61
62
+ create_service_user ${MGMTWORKER_USER} ${MGMTWORKER_HOME} /bin/bash
63
+
64
+ # This directory is populated when deployments are created- counterintuitively it does need to live here rather than the riemann component
65
+ create_dir ${MGMTWORKER_RIEMANN_POLICY_DIR}
66
+ set_directory_tree_ownership ${MGMTWORKER_USER} ${MGMTWORKER_GROUP} ${MGMTWORKER_RIEMANN_POLICY_DIR}
67
+
54
68
# this create the MGMTWORKER_VIRTUALENV_DIR and installs the relevant modules into it.
55
69
yum_install ${MANAGEMENT_WORKER_RPM_SOURCE_URL}
56
70
@@ -98,4 +112,27 @@ for python_path in ${MGMTWORKER_VIRTUALENV_DIR}/lib/python*; do
98
112
# The config contains credentials, do not let the world read it
99
113
chmod 440 " ${BROKER_CONF_PATH} "
100
114
done
115
+
116
+ # Copy or move key files to appropriate locations
117
+ if sudo test -f /root/.ssh/agent_key.pem; then
118
+ sudo mv /root/.ssh/agent_key.pem /opt/mgmtworker
119
+ else
120
+ # If the key file wasn't where we expected then we're probably running a simple-manager-blueprint
121
+ # If this fails, the management worker wouldn't be able to ssh into any compute nodes, so failing is acceptable
122
+ # Using this ugly approach because tilde expansion isn't working here. This should be fixed when we standardise
123
+ # key locations.
124
+ sudo cp ${SSH_KEY_FILE/ \~ / \/ home\/ ${AGENT_USER} } /opt/mgmtworker/agent_key.pem
125
+ fi
126
+
127
+ # Set ownership
128
+ set_directory_tree_ownership ${MGMTWORKER_USER} ${MGMTWORKER_GROUP} ${MGMTWORKER_HOME}
129
+ set_directory_tree_ownership ${MGMTWORKER_USER} ${MGMTWORKER_GROUP} ${MGMTWORKER_VIRTUALENV_DIR}
130
+ set_directory_tree_ownership ${MGMTWORKER_USER} ${MGMTWORKER_GROUP} ${CELERY_WORK_DIR}
131
+ set_directory_tree_ownership ${MGMTWORKER_USER} ${MGMTWORKER_GROUP} ${CELERY_LOG_DIR}
132
+
133
+ # Management worker has to create services
134
+ # TODO: It would be better if we made a specific script and allowed sudo only for that script to allow the services to be created.
135
+ # This requires modifications to the agent as well, and may require modification to the agent installer.
136
+ allow_sudo_for_user ${MGMTWORKER_USER}
137
+
101
138
configure_systemd_service " mgmtworker"
0 commit comments