cytopia / ansible-role-cloudformation Goto Github PK
View Code? Open in Web Editor NEWAnsible role to render an arbitrary number of Jinja2 templates into cloudformation files and create any number of stacks.
License: MIT License
Ansible role to render an arbitrary number of Jinja2 templates into cloudformation files and create any number of stacks.
License: MIT License
Hey,
Great role, here's a feature request.. I would raise a PR but this is such a trivial change - how about if we also allow Termination Protection via a protect
flag?
$ git diff roles/galaxy/
diff --git a/ansible/roles/galaxy/cytopia.cloudformation/tasks/run.yml b/ansible/roles/galaxy/cytopia.cloudformation/tasks/run.yml
index 3f584b8..eb0cd9a 100644
--- a/ansible/roles/galaxy/cytopia.cloudformation/tasks/run.yml
+++ b/ansible/roles/galaxy/cytopia.cloudformation/tasks/run.yml
@@ -80,6 +80,7 @@
profile: "{{ cloudformation.profile | default(cloudformation_defaults.profile | default(omit)) }}"
region: "{{ cloudformation.region | default(cloudformation_defaults.region | default(omit)) }}"
notification_arns: "{{ cloudformation.notification_arns | default(cloudformation_defaults.notification_arns | default(omit)) }}"
+ termination_protection: "{{ cloudformation.protect | default(False) }}"
template_parameters: "{{ cloudformation.template_parameters | default(omit) }}"
tags: "{{ cloudformation.tags | default(omit) }}"
when: not cloudformation_generate_only
Hey!
Looks like cloudformation_diff script doesn't work anymore. Tried with latest ansible available in python:3-alpine docker image
TASK [ansible-role-cloudformation : diff cloudformation template parameters] ***********************************************************************************************************************************************************************************************************************************************
fatal: [infrastructure]: FAILED! => {
"changed": false,
"rc": 1
}
MSG:
MODULE FAILURE
See stdout/stderr for the exact error
MODULE_STDERR:
/root/.ansible/tmp/ansible-tmp-1563169478.9655852-25792851061594/AnsiballZ_cloudformation_diff.py:18: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1563169478.9655852-25792851061594/AnsiballZ_cloudformation_diff.py", line 114, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1563169478.9655852-25792851061594/AnsiballZ_cloudformation_diff.py", line 106, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1563169478.9655852-25792851061594/AnsiballZ_cloudformation_diff.py", line 49, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/usr/local/lib/python3.7/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/usr/local/lib/python3.7/imp.py", line 169, in load_source
module = _exec(spec, sys.modules[name])
File "<frozen importlib._bootstrap>", line 630, in _exec
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/ansible_cloudformation_diff_payload_35lmcfal/__main__.py", line 590, in <module>
File "/tmp/ansible_cloudformation_diff_payload_35lmcfal/__main__.py", line 488, in main
AttributeError: 'str' object has no attribute 'decode'
PLAY RECAP *****************************************************************************************************************************************************************************************************************************************************************************************************************
infrastructure : ok=8 changed=0 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0
/src # python -V
Python 3.7.4
/src # pip list | egrep "(boto|cfn)"
boto3 1.9.188
botocore 1.12.188
cfn-flip 1.2.1
/src #
When using this role to apply templates to multiple AWS accounts, I often need slightly different results from the rendering per account. An example would be when the template will include the account's ID - that value must differ between the 'hosts' (accounts). The fix is trivial:
$ git diff tasks/
diff --git a/tasks/run.yml b/tasks/run.yml
index 28ea31c..cf38a20 100644
--- a/tasks/run.yml
+++ b/tasks/run.yml
@@ -5,7 +5,7 @@
###
- name: register a sane template name
set_fact:
- cloudformation_file_name: "{{ cloudformation.template | basename }}-{{ cloudformation.stack_name }}.yml"
+ cloudformation_file_name: "{{ inventory_hostname + '-' + cloudformation.template | basename }}-{{ cloudformation.stack_name }}.yml"
check_mode: False
.. we just include the inventory_hostname
in the rendered template path. Worth considering?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.