Merge pull request #248 from loles/librarian_resource

Librarian resource
This commit is contained in:
Dmitry Shulyak 2015-10-13 14:12:15 +03:00
commit df18ed61c7
6 changed files with 89 additions and 0 deletions

15
examples/librarian/README Normal file
View File

@ -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
```

View File

@ -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

View File

@ -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

View File

@ -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}}

View File

@ -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

View File

@ -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 -%}