diff --git a/examples/librarian/README b/examples/librarian/README new file mode 100644 index 00000000..ca51c478 --- /dev/null +++ b/examples/librarian/README @@ -0,0 +1,15 @@ +Usage +===== + +Run it from /vagrant dir: + +``` +solar resource clear_all +solar resource create nodes templates/nodes.yaml '{"count": 1}' +solar resource create librarian_example examples/librarian/librarian.yaml '{"node": "node1"}' + +solar changes stage +solar changes process +solar orch run-once +solar orch report -w 100 +``` diff --git a/examples/librarian/librarian.yaml b/examples/librarian/librarian.yaml new file mode 100644 index 00000000..79445de5 --- /dev/null +++ b/examples/librarian/librarian.yaml @@ -0,0 +1,21 @@ +id: librarian_examples + +resources: + - id: librarian + location: {{node}} + from: resources/librarian + values: + modules_path: /tmp/x/x/modules + modules: + - name: puppetlabs-ntp + version: 4.1.0 + - name: puppet-keystone + type: git + url: https://github.com/openstack/puppet-keystone + ref: 5.1.0 + +events: + - type: depends_on + parent_action: librarian.run + state: success + depend_action: rabbitmq_service1.run diff --git a/resources/librarian/actions/remove.yaml b/resources/librarian/actions/remove.yaml new file mode 100644 index 00000000..c948ead8 --- /dev/null +++ b/resources/librarian/actions/remove.yaml @@ -0,0 +1,6 @@ +- hosts: [{{host}}] + sudo: yes + tasks: + - file: path={{modules_path}} state=absent + - file: path={{modules_path}}/../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..391e6f8a --- /dev/null +++ b/resources/librarian/actions/run.yaml @@ -0,0 +1,10 @@ +- 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 + - file: path={{modules_path}} state=directory + - template: + src={{templates_dir}}/Puppetfile + dest={{modules_path}}/../Puppetfile + - shell: librarian-puppet install chdir={{modules_path}} diff --git a/resources/librarian/meta.yaml b/resources/librarian/meta.yaml new file mode 100644 index 00000000..9d620c11 --- /dev/null +++ b/resources/librarian/meta.yaml @@ -0,0 +1,13 @@ +id: librarian +handler: ansible +version: 0.0.1 +input: + modules: + schema: [str] + value: [] + modules_path: + schema: str! + value: /etc/puppet/modules + 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 -%}