From da0b6001ce116cd39793d02193dcfab54215ce86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Sun, 11 Oct 2015 23:40:51 +0200 Subject: [PATCH 1/5] Librarian resource --- resources/librarian/actions/remove.yaml | 6 ++++++ resources/librarian/actions/run.yaml | 9 +++++++++ resources/librarian/meta.yaml | 14 ++++++++++++++ resources/librarian/templates/Puppetfile | 24 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 resources/librarian/actions/remove.yaml create mode 100644 resources/librarian/actions/run.yaml create mode 100644 resources/librarian/meta.yaml create mode 100644 resources/librarian/templates/Puppetfile 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 -%} From e47da66d0df058a177ba8f0c7805321bac334d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Mon, 12 Oct 2015 08:21:08 +0200 Subject: [PATCH 2/5] Remove reverse option --- resources/librarian/meta.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/librarian/meta.yaml b/resources/librarian/meta.yaml index 97903c39..083cae73 100644 --- a/resources/librarian/meta.yaml +++ b/resources/librarian/meta.yaml @@ -5,7 +5,6 @@ input: modules: schema: [str] value: [] - reverse: True config_dir: schema: str! value: /etc/puppet From f75aefabc99671d37f344e03752548154e412877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Mon, 12 Oct 2015 09:24:07 +0200 Subject: [PATCH 3/5] Add librarian example --- examples/librarian/README | 15 +++++++++++++++ examples/librarian/librarian.yaml | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 examples/librarian/README create mode 100644 examples/librarian/librarian.yaml 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..a0ee2d6a --- /dev/null +++ b/examples/librarian/librarian.yaml @@ -0,0 +1,20 @@ +id: librarian_examples + +resources: + - id: librarian + location: {{node}} + from: resources/librarian + values: + 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 From 82d81154b76c993654bc934ca0483a471adacc13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Tue, 13 Oct 2015 12:10:49 +0200 Subject: [PATCH 4/5] Modify and rename config_dir input to modules_dir. --- examples/librarian/librarian.yaml | 1 + resources/librarian/actions/remove.yaml | 4 ++-- resources/librarian/actions/run.yaml | 5 +++-- resources/librarian/meta.yaml | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/librarian/librarian.yaml b/examples/librarian/librarian.yaml index a0ee2d6a..a5731757 100644 --- a/examples/librarian/librarian.yaml +++ b/examples/librarian/librarian.yaml @@ -5,6 +5,7 @@ resources: location: {{node}} from: resources/librarian values: + modules_dir: /tmp/x/x/modules modules: - name: puppetlabs-ntp version: 4.1.0 diff --git a/resources/librarian/actions/remove.yaml b/resources/librarian/actions/remove.yaml index 7b496c2f..42c4616c 100644 --- a/resources/librarian/actions/remove.yaml +++ b/resources/librarian/actions/remove.yaml @@ -1,6 +1,6 @@ - hosts: [{{host}}] sudo: yes tasks: - #XXX: should we remove modules also? - - file: path={{config_dir}}/Puppetfile state=absent + - file: path={{modules_dir}} state=absent + - file: path={{modules_dir}}/../Puppetfile state=absent - shell: gem uninstall librarian-puppet diff --git a/resources/librarian/actions/run.yaml b/resources/librarian/actions/run.yaml index fa04b49f..1f69649c 100644 --- a/resources/librarian/actions/run.yaml +++ b/resources/librarian/actions/run.yaml @@ -3,7 +3,8 @@ 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_dir}} state=directory - template: src={{templates_dir}}/Puppetfile - dest={{config_dir}}/Puppetfile - - shell: librarian-puppet install chdir={{config_dir}} + dest={{modules_dir}}/../Puppetfile + - shell: librarian-puppet install chdir={{modules_dir}} diff --git a/resources/librarian/meta.yaml b/resources/librarian/meta.yaml index 083cae73..77213fdd 100644 --- a/resources/librarian/meta.yaml +++ b/resources/librarian/meta.yaml @@ -5,9 +5,9 @@ input: modules: schema: [str] value: [] - config_dir: + modules_dir: schema: str! - value: /etc/puppet + value: /etc/puppet/modules forge: schema: str! value: https://forgeapi.puppetlabs.com From 585eb5029130bb98f46f4211e781f6aa224acbf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Tue, 13 Oct 2015 12:34:51 +0200 Subject: [PATCH 5/5] Use modules_path name --- examples/librarian/librarian.yaml | 2 +- resources/librarian/actions/remove.yaml | 4 ++-- resources/librarian/actions/run.yaml | 6 +++--- resources/librarian/meta.yaml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/librarian/librarian.yaml b/examples/librarian/librarian.yaml index a5731757..79445de5 100644 --- a/examples/librarian/librarian.yaml +++ b/examples/librarian/librarian.yaml @@ -5,7 +5,7 @@ resources: location: {{node}} from: resources/librarian values: - modules_dir: /tmp/x/x/modules + modules_path: /tmp/x/x/modules modules: - name: puppetlabs-ntp version: 4.1.0 diff --git a/resources/librarian/actions/remove.yaml b/resources/librarian/actions/remove.yaml index 42c4616c..c948ead8 100644 --- a/resources/librarian/actions/remove.yaml +++ b/resources/librarian/actions/remove.yaml @@ -1,6 +1,6 @@ - hosts: [{{host}}] sudo: yes tasks: - - file: path={{modules_dir}} state=absent - - file: path={{modules_dir}}/../Puppetfile state=absent + - 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 index 1f69649c..391e6f8a 100644 --- a/resources/librarian/actions/run.yaml +++ b/resources/librarian/actions/run.yaml @@ -3,8 +3,8 @@ 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_dir}} state=directory + - file: path={{modules_path}} state=directory - template: src={{templates_dir}}/Puppetfile - dest={{modules_dir}}/../Puppetfile - - shell: librarian-puppet install chdir={{modules_dir}} + dest={{modules_path}}/../Puppetfile + - shell: librarian-puppet install chdir={{modules_path}} diff --git a/resources/librarian/meta.yaml b/resources/librarian/meta.yaml index 77213fdd..9d620c11 100644 --- a/resources/librarian/meta.yaml +++ b/resources/librarian/meta.yaml @@ -5,7 +5,7 @@ input: modules: schema: [str] value: [] - modules_dir: + modules_path: schema: str! value: /etc/puppet/modules forge: