Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2017 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f8208852a2105eb4c37c5eb04025abec to your computer and use it in GitHub Desktop.
Save anonymous/f8208852a2105eb4c37c5eb04025abec to your computer and use it in GitHub Desktop.
How can I create a map.jinja file for liquibase that defines and sets liquibase_root & others from pillar data?
# liquibase pillar - there currently exists no map.jinja
##################
liquibase:
version: 3.1.1
checksum: 91c237126ad37703e8e04bb49235044c
url: 'https://github.com/liquibase/liquibase/releases/download/liquibase-parent-{0}/liquibase-{0}-bin.tar.gz'
install_root: /opt
jdbc_drivers:
postgres:
url: https://jdbc.postgresql.org/download/postgresql-42.1.4.jar
checksum: 412b760d4a114aff550a0374f09f15f9
#liquibase state
################
{% set liquibase = salt.pillar.get('liquibase', {}) %}
{% set liquibase_root = '{0}/liquibase-{1}'.format(liquibase.install_root, liquibase.version) %} ## REMEMBER THIS
liquibase_download:
archive.extracted:
- name: {{ liquibase_root }}
- source: {{ liquibase.get('url', '').format(liquibase.get('version', ''))}}
- source_hash: {{ liquibase.checksum }}
- enforce_toplevel: False
- user: root
- group: root
{% set jdbc_drivers = liquibase.get('jdbc_drivers', {}) %}
{% if jdbc_drivers.postgres is defined %}
liquibase_jdbc_driver_postgres:
file.managed:
- name: {{ liquibase_root }}/lib/{{ salt.file.basename(jdbc_drivers.postgres.url) }}
- source: {{ jdbc_drivers.postgres.url }}
- source_hash: {{ jdbc_drivers.postgres.checksum }}
- user: root
- group: root
- require:
- archive: liquibase_download
{% endif %}
# deploy code state
###################
{% set itman = salt.pillar.get('itman', {}) %}
# Import other formula dictionaries into template
{% from "apache/map.jinja" import apache with context %}
{% from "tomcat/map.jinja" import tomcat with context %}
{% set liquibase = salt.pillar.get('liquibase', {}) %}
# Clone itman repo to the target location
itman_cloned_to_target:
git.latest:
- name: git@bitbucket.org:opentempo/itman.git
- target: {{ itman.target_dir }}
- branch: master
- force_checout: True # Discard unwritten changed when checking out.
- force_clone: True # Remove the contents of the target idrectory and clone the repo into it.
- identity: /root/.ssh/id_rsa
# Render the itman configuration file
itman_config:
file.managed:
- name: {{ itman.configuration.yml }}
- source: salt://itman/files/configuration.yml.jinja
- user: root
- group: root
- context:
- itman: {{ itman }}
- apache: {{ apache }}
- tomcat: {{ tomcat }}
- liquibase: {{ liquibase }}
# deploy code template
######################
# I need access to {{ liquibase_root }} HERE, but it only exists in liquibase state. Same is true for a bunch of other variables I haven't defined yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment