diff --git a/.gitignore b/.gitignore
index 333181b..98ba6eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ supervisord.*
.DS_Store
xl-deploy-9.6.0-server/
+xl-deploy-9.6.1-server/
diff --git a/src/main/resources/ansible_step/ansible-playbook.sh.ftl b/src/main/resources/ansible_step/ansible-playbook.sh.ftl
index f8f8421..a59d665 100644
--- a/src/main/resources/ansible_step/ansible-playbook.sh.ftl
+++ b/src/main/resources/ansible_step/ansible-playbook.sh.ftl
@@ -12,11 +12,13 @@
export PYTHONUNBUFFERED=1
export ANSIBLE_CONFIG=ansible.cfg
+echo "${devopsAsCodeTemplate}" > ${deployed.name}.j2
+
<#assign verbose=""/>
<#if ansibleController.debug>
<#assign verbose="-v"/>
echo "= xldeploy_playbook.yml ="
-cat xldeploy_playbook.yml
+cat -n xldeploy_playbook.yml
echo "= inventory = "
cat ansible_step/inventory/xldeploy_ansible_inventory
@@ -27,6 +29,9 @@ cat ansible_step/xldeploy_extravars.json
echo "= ansible.cfg = "
cat ansible.cfg
+echo "= ${deployed.name}.j2 = "
+cat ${deployed.name}.j2
+
echo "------ "
find . -ls
echo "------ "
diff --git a/src/main/resources/planning/joiner.devopsascode.templates.py b/src/main/resources/planning/joiner.devopsascode.templates.py
new file mode 100644
index 0000000..c5790ca
--- /dev/null
+++ b/src/main/resources/planning/joiner.devopsascode.templates.py
@@ -0,0 +1,34 @@
+#
+# Copyright 2020 XEBIALABS
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+
+from org.apache.commons.io import IOUtils
+
+
+def to_string(from_file, charset):
+ return IOUtils.toString(from_file.getInputStream(), charset)
+
+
+def roles():
+ result = []
+ for _delta in specification.deltas:
+ deployed = _delta.deployedOrPrevious
+ if (_delta.operation == "CREATE" or _delta.operation == "MODIFY") and deployed.type == "ansible.Roles":
+ result.append(deployed)
+ return set(result)
+
+
+for role in roles():
+ data = ""
+ for template in role.devopsAsCodeTemplates:
+ content = to_string(template.file, "UTF-8")
+ data = data + content
+ #print(data)
+ role.computedDevopsAsCodeTemplate = data
diff --git a/src/main/resources/synthetic.xml b/src/main/resources/synthetic.xml
index 1fe56c4..6fb499a 100644
--- a/src/main/resources/synthetic.xml
+++ b/src/main/resources/synthetic.xml
@@ -29,7 +29,7 @@
-
+
@@ -43,9 +43,17 @@
+
+
+
+
+
+
+
+
@@ -71,6 +72,7 @@
deployed.container.ansibleController
deployedApplication
yes
+ deployed.computedDevopsAsCodeTemplate
ansible_step/inventory/xldeploy_ansible_inventory.ftl
@@ -86,6 +88,10 @@
planning/ssh-keys-remote-loader.py
+
+ planning/joiner.devopsascode.templates.py
+
+
ansible.Roles
@@ -100,6 +106,7 @@
deployed.galaxyRoles
deployed.variables
deployed.variableFile
+ context.getAttribute("{0}_computedDevopsAsCodeTemplate".format(deployed.id))
diff --git a/src/main/resources/xldeploy_playbook.yml.ftl b/src/main/resources/xldeploy_playbook.yml.ftl
index 4e1b3d8..dffdb8f 100644
--- a/src/main/resources/xldeploy_playbook.yml.ftl
+++ b/src/main/resources/xldeploy_playbook.yml.ftl
@@ -20,3 +20,17 @@
<#list roles as role>
- { role: ${role} }
#list>
+ tasks:
+<#list deployed.devopsAsCodeTemplates as template>
+ - name: Generate the Devops-As-Code
+ template:
+ src: ${deployed.name}.j2
+ dest: /tmp/digital.ai_xldeploy.yaml
+ mode: 0755
+ - name: Fetch the Devops-As-Code yaml file on the master
+ fetch:
+ src: /tmp/digital.ai_xldeploy.yaml
+ dest: "{{ devops_as_code_directory }}"
+ flat: no
+#list>
+