diff --git a/README.rst b/README.rst index 913fa3f..9a2c504 100644 --- a/README.rst +++ b/README.rst @@ -19,3 +19,8 @@ Available states ---------- Install packer and add it to PATH + +``packer.templates`` +---------- + +Manage templates repositories for Packer diff --git a/packer/defaults.yml b/packer/defaults.yml index bbf08c4..2a0bb7c 100644 --- a/packer/defaults.yml +++ b/packer/defaults.yml @@ -7,7 +7,8 @@ default: version: '1.4.2' path: extract_to: /opt/packer/VERSION - profile: /etc/profile.d/packer.sh + profile: /etc/profile.d/packer.sh + templates: /srv/packer/templates #Debian: #Suse: #Arch: diff --git a/packer/templates.sls b/packer/templates.sls new file mode 100644 index 0000000..3671488 --- /dev/null +++ b/packer/templates.sls @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{%- from "packer/map.jinja" import packer with context %} + +packer_templates_create_directory: + file.directory: + - name: {{ packer.path.templates }} + - makedirs: True + +{%- for repo_name, repo in salt['pillar.get']('packer:lookup:templates', {}).items() %} + +{%- if repo == None %} +{%- set repo = {} %} +{%- endif %} + +{%- set address = repo.get('address') %} +{%- set revision = repo.get('revision', 'master') %} + +packer_templates_git_repo_{{ repo_name }}: + git.latest: + - name: {{ address }} + - target: {{ packer.path.templates }}/{{ repo_name }} + - rev: {{ revision }} + - require: + - file: packer_templates_create_directory + +{%- endfor %} diff --git a/pillar.example b/pillar.example index c06d17b..23d3781 100644 --- a/pillar.example +++ b/pillar.example @@ -3,3 +3,9 @@ packer: download: version: '0.11.0' hash: "sha256=318ffffa13763eb6f29f28f572656356dc3dbf8d54c01ffddd1c5e2f08593adb" + templates: + ubuntu: + address: https://github.com/boxcutter/ubuntu.git + revision: master + bento: + address: https://github.com/chef/bento.git