diff --git a/resources/librarian/actions/remove.yaml b/resources/librarian/actions/remove.yaml new file mode 100644 index 00000000..7b496c2f --- /dev/null +++ b/resources/librarian/actions/remove.yaml @@ -0,0 +1,6 @@ +- hosts: [{{host}}] + sudo: yes + tasks: + #XXX: should we remove modules also? + - file: path={{config_dir}}/Puppetfile state=absent + - shell: gem uninstall librarian-puppet diff --git a/resources/librarian/actions/run.yaml b/resources/librarian/actions/run.yaml new file mode 100644 index 00000000..fa04b49f --- /dev/null +++ b/resources/librarian/actions/run.yaml @@ -0,0 +1,9 @@ +- hosts: [{{host}}] + sudo: yes + tasks: + # XXX: check apt package http://packages.ubuntu.com/trusty/ruby/librarian-puppet + - shell: gem install librarian-puppet --no-ri --no-rdoc + - template: + src={{templates_dir}}/Puppetfile + dest={{config_dir}}/Puppetfile + - shell: librarian-puppet install chdir={{config_dir}} diff --git a/resources/librarian/meta.yaml b/resources/librarian/meta.yaml new file mode 100644 index 00000000..97903c39 --- /dev/null +++ b/resources/librarian/meta.yaml @@ -0,0 +1,14 @@ +id: librarian +handler: ansible +version: 0.0.1 +input: + modules: + schema: [str] + value: [] + reverse: True + config_dir: + schema: str! + value: /etc/puppet + forge: + schema: str! + value: https://forgeapi.puppetlabs.com diff --git a/resources/librarian/templates/Puppetfile b/resources/librarian/templates/Puppetfile new file mode 100644 index 00000000..90ba1d92 --- /dev/null +++ b/resources/librarian/templates/Puppetfile @@ -0,0 +1,24 @@ +forge "{{forge}}" + +{%- for module in modules %} + + {% if 'type' not in module or module.type == 'forge' -%} +mod '{{module.name}}' + {%- if 'version' in module -%} +, '{{module.version}}' + {%- endif -%} + {%- endif -%} + + {%- if 'type' in module and module.type == 'git' -%} +mod '{{module.name}}' + {%- if 'url' in module -%} +, + :git => '{{module.url}}' + {%- endif -%} + {%- if 'ref' in module -%} +, + :ref => '{{module.ref}}' + {%- endif -%} + {%- endif -%} + +{%- endfor -%}