From 5d2eb42f0a600fc4e262dabdee36e0440cdb2537 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Thu, 11 Jan 2018 10:59:38 +0100 Subject: [openstack] custom user commands for cloud-init Allow to specify additional user commands executed on all Nova servers provisioned via Heat. An example use case is installing and starting os-collect-config agents to put Nova servers under the configuration management driven via the host openstack cloud Heat services. This allows to integrate with another deployment tools like TripleO. Signed-off-by: Bogdan Dobrelya --- roles/openshift_openstack/defaults/main.yml | 2 ++ roles/openshift_openstack/templates/user_data.j2 | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'roles/openshift_openstack') diff --git a/roles/openshift_openstack/defaults/main.yml b/roles/openshift_openstack/defaults/main.yml index 2bdb81632..4e3b7939a 100644 --- a/roles/openshift_openstack/defaults/main.yml +++ b/roles/openshift_openstack/defaults/main.yml @@ -94,6 +94,8 @@ openshift_openstack_etcd_volume_size: 2 openshift_openstack_lb_volume_size: 5 openshift_openstack_ephemeral_volumes: false +# User commands for cloud-init executed on all Nova servers provisioned +openshift_openstack_provision_user_commands: [] # cloud-config openshift_openstack_disable_root: true diff --git a/roles/openshift_openstack/templates/user_data.j2 b/roles/openshift_openstack/templates/user_data.j2 index ccaa5d464..e8185edfb 100644 --- a/roles/openshift_openstack/templates/user_data.j2 +++ b/roles/openshift_openstack/templates/user_data.j2 @@ -11,3 +11,10 @@ write_files: permissions: 440 content: | Defaults:openshift !requiretty + +{% if openshift_openstack_provision_user_commands %} +runcmd: +{% for cmd in openshift_openstack_provision_user_commands %} + - {{ cmd }} +{% endfor %} +{% endif %} -- cgit v1.2.3 From c9cce6db686588b977968bc65a10dc5039a08a23 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Thu, 11 Jan 2018 10:59:38 +0100 Subject: Fix openstack cloud-init runcmd templating Signed-off-by: Bogdan Dobrelya --- roles/openshift_openstack/templates/user_data.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'roles/openshift_openstack') diff --git a/roles/openshift_openstack/templates/user_data.j2 b/roles/openshift_openstack/templates/user_data.j2 index e8185edfb..b8692b1ae 100644 --- a/roles/openshift_openstack/templates/user_data.j2 +++ b/roles/openshift_openstack/templates/user_data.j2 @@ -15,6 +15,6 @@ write_files: {% if openshift_openstack_provision_user_commands %} runcmd: {% for cmd in openshift_openstack_provision_user_commands %} - - {{ cmd }} + - {{ cmd|map('string')|list|tojson }} {% endfor %} {% endif %} -- cgit v1.2.3 From 5c1850b43582f8449070399df5c32c3fcd8688e2 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 12 Jan 2018 16:24:49 +0100 Subject: Clarify the ansible playbook vs cloud-init Document use cases for custom post-provision ansible hooks vs cloud-init runcmd shell commands. Rename to openshift_openstack_cloud_init_runcmd. Signed-off-by: Bogdan Dobrelya --- roles/openshift_openstack/templates/user_data.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'roles/openshift_openstack') diff --git a/roles/openshift_openstack/templates/user_data.j2 b/roles/openshift_openstack/templates/user_data.j2 index b8692b1ae..e130e71c3 100644 --- a/roles/openshift_openstack/templates/user_data.j2 +++ b/roles/openshift_openstack/templates/user_data.j2 @@ -12,9 +12,9 @@ write_files: content: | Defaults:openshift !requiretty -{% if openshift_openstack_provision_user_commands %} +{% if openshift_openstack_cloud_init_runcmd %} runcmd: -{% for cmd in openshift_openstack_provision_user_commands %} +{% for cmd in openshift_openstack_cloud_init_runcmd %} - {{ cmd|map('string')|list|tojson }} {% endfor %} {% endif %} -- cgit v1.2.3 From d03e39704e8148fa1cf1869c0e5003ecf48c4f57 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Mon, 15 Jan 2018 09:45:14 +0100 Subject: Fix cloud init runcmd templating Signed-off-by: Bogdan Dobrelya --- roles/openshift_openstack/templates/user_data.j2 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'roles/openshift_openstack') diff --git a/roles/openshift_openstack/templates/user_data.j2 b/roles/openshift_openstack/templates/user_data.j2 index e130e71c3..352744285 100644 --- a/roles/openshift_openstack/templates/user_data.j2 +++ b/roles/openshift_openstack/templates/user_data.j2 @@ -13,8 +13,17 @@ write_files: Defaults:openshift !requiretty {% if openshift_openstack_cloud_init_runcmd %} -runcmd: + - path: /root/ansible_install.sh + permissions: '0544' + content: | {% for cmd in openshift_openstack_cloud_init_runcmd %} - - {{ cmd|map('string')|list|tojson }} +{% if cmd is string %} + {{ cmd }} +{% elif cmd is iterable %} + {{ cmd|join(' ') }} +{% endif %} {% endfor %} + +runcmd: + - /root/ansible_install.sh {% endif %} -- cgit v1.2.3 From aafbd31f00f48ee9e3e1aaea8f5f316669262872 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Mon, 12 Feb 2018 15:39:23 +0100 Subject: Fix openshift_openstack_provision_user_commands Signed-off-by: Bogdan Dobrelya --- roles/openshift_openstack/templates/user_data.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'roles/openshift_openstack') diff --git a/roles/openshift_openstack/templates/user_data.j2 b/roles/openshift_openstack/templates/user_data.j2 index 352744285..1ca87a429 100644 --- a/roles/openshift_openstack/templates/user_data.j2 +++ b/roles/openshift_openstack/templates/user_data.j2 @@ -12,11 +12,11 @@ write_files: content: | Defaults:openshift !requiretty -{% if openshift_openstack_cloud_init_runcmd %} +{% if openshift_openstack_provision_user_commands %} - path: /root/ansible_install.sh permissions: '0544' content: | -{% for cmd in openshift_openstack_cloud_init_runcmd %} +{% for cmd in openshift_openstack_provision_user_commands %} {% if cmd is string %} {{ cmd }} {% elif cmd is iterable %} -- cgit v1.2.3