librarian-ansible 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +109 -0
- data/Rakefile +1 -0
- data/bin/librarian-ansible +7 -0
- data/lib/ext/librarian/dsl/target.rb +40 -0
- data/lib/ext/librarian/lockfile/parser.rb +51 -0
- data/lib/librarian-ansible.rb +1 -0
- data/lib/librarian/ansible.rb +1 -0
- data/lib/librarian/ansible/cli.rb +47 -0
- data/lib/librarian/ansible/dsl.rb +18 -0
- data/lib/librarian/ansible/environment.rb +34 -0
- data/lib/librarian/ansible/extension.rb +10 -0
- data/lib/librarian/ansible/manifest_reader.rb +47 -0
- data/lib/librarian/ansible/source.rb +5 -0
- data/lib/librarian/ansible/source/galaxy.rb +57 -0
- data/lib/librarian/ansible/source/git.rb +26 -0
- data/lib/librarian/ansible/source/github.rb +29 -0
- data/lib/librarian/ansible/source/local.rb +75 -0
- data/lib/librarian/ansible/source/path.rb +14 -0
- data/lib/librarian/ansible/source/site.rb +30 -0
- data/lib/librarian/ansible/version.rb +5 -0
- data/librarian-ansible.gemspec +26 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e183c081e6dbd0eb76ad8b8b9f62ea83459429a6
|
4
|
+
data.tar.gz: 8bb3dd88a04994a713d843ce4b6c374987816300
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e08a50aa39ba81791554532f007a5987be960dcee595343679c3d5b141a709fe3fd3801bcb136bc0370292d8bb8d304bb1b7fa31dc549c4f0ec7fdbcbab0f3f7
|
7
|
+
data.tar.gz: 109e4af9987d4a57bbb9315be867c1adccffba11b84d8292bcaa6a58f89550f901bbd99f2a8aef302307bd9ac4021dc494dd0a62441ef6597d17ab7326e24571
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
roles
|
19
|
+
librarian_roles
|
20
|
+
Ansiblefile
|
21
|
+
Ansiblefile.lock
|
22
|
+
npm-debug.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 bcoe
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
Librarian::Ansible
|
2
|
+
=================
|
3
|
+
|
4
|
+
Port of librarian-chef, providing bundler functionality for Ansible roles.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install librarian-ansible
|
11
|
+
```
|
12
|
+
|
13
|
+
Ansiblefile: Describing Your Dependencies
|
14
|
+
---------------------------------------------
|
15
|
+
|
16
|
+
To document the external Ansible roles you rely on, simply place them in an Ansiblefile:
|
17
|
+
|
18
|
+
_An Example Ansiblefile:_
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
#!/usr/bin/env ruby
|
22
|
+
#^syntax detection
|
23
|
+
|
24
|
+
site "https://galaxy.ansible.com/api/v1"
|
25
|
+
|
26
|
+
role "kunik.deploy-upstart-scripts"
|
27
|
+
|
28
|
+
role "pgolm.ansible-playbook-monit",
|
29
|
+
github: "pgolm/ansible-playbook-monit"
|
30
|
+
|
31
|
+
role "ansible-role-nagios-nrpe-server",
|
32
|
+
">=0.0.0",
|
33
|
+
path: "./roles/ansible-role-nagios-nrpe-server"
|
34
|
+
```
|
35
|
+
|
36
|
+
Your dependencies can be:
|
37
|
+
|
38
|
+
* Ansible Galaxy IDs:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
role "kunik.deploy-upstart-scripts"
|
42
|
+
```
|
43
|
+
|
44
|
+
* paths to local files:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
role "ansible-role-nagios-nrpe-server", path: "./roles/ansible-role-nagios-nrpe-server"
|
48
|
+
```
|
49
|
+
|
50
|
+
* Github username/project pairs:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
role "pgolm.ansible-playbook-monit", github: "pgolm/ansible-playbook-monit"
|
54
|
+
```
|
55
|
+
|
56
|
+
* Git repos:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
role "pgolm.ansible-playbook-monit", git: "git@github.com:pgolm/ansible-playbook-monit.git"
|
60
|
+
```
|
61
|
+
|
62
|
+
Installing Dependencies
|
63
|
+
-----------------------
|
64
|
+
|
65
|
+
To install your dependencies, simply run:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
librarian-ansible install
|
69
|
+
```
|
70
|
+
|
71
|
+
The first time you run this, an Ansible.lock file will be created which should be checked into your repo. This file ensures that other developers are pinned to the appropriate role versions.
|
72
|
+
|
73
|
+
On Version #s
|
74
|
+
-------------
|
75
|
+
|
76
|
+
librarian-ansible supports version #s, simply add one to your `meta/main.yml` file:
|
77
|
+
|
78
|
+
```yml
|
79
|
+
---
|
80
|
+
galaxy_info:
|
81
|
+
author: Peter Golm
|
82
|
+
license: MIT
|
83
|
+
min_ansible_version: 1.4
|
84
|
+
platforms:
|
85
|
+
- name: Ubuntu
|
86
|
+
versions:
|
87
|
+
- raring
|
88
|
+
- saucy
|
89
|
+
|
90
|
+
categories:
|
91
|
+
- monitoring
|
92
|
+
- system
|
93
|
+
dependencies: []
|
94
|
+
version: 2.0.0
|
95
|
+
```
|
96
|
+
|
97
|
+
And update your Ansiblefile accordingly:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
role "kunik.deploy-upstart-scripts", "1.0.0"
|
101
|
+
```
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
1. Fork it ( http://github.com/<my-github-username>/librarian-ansible/fork )
|
106
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
107
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
108
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
109
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'librarian/spec'
|
2
|
+
|
3
|
+
# Override the default librarian DSL to pass the 'name'
|
4
|
+
# parameter to a source.
|
5
|
+
module Librarian
|
6
|
+
class Dsl
|
7
|
+
class Target
|
8
|
+
|
9
|
+
def dependency(name, *args)
|
10
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
11
|
+
source = source_from_options(options, name) || @source
|
12
|
+
dep = dependency_type.new(name, args, source)
|
13
|
+
@dependencies << dep
|
14
|
+
end
|
15
|
+
|
16
|
+
def source_from_options(options, name = nil)
|
17
|
+
if options[:source]
|
18
|
+
source_shortcuts[options[:source]]
|
19
|
+
elsif source_parts = extract_source_parts(options, name)
|
20
|
+
source_from_params(*source_parts)
|
21
|
+
else
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract_source_parts(options, name = nil)
|
27
|
+
options = {:galaxy => name} if options.empty?
|
28
|
+
|
29
|
+
if name = source_type_names.find{|name| options.key?(name)}
|
30
|
+
options = options.dup
|
31
|
+
param = options.delete(name)
|
32
|
+
[name, param, options]
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'librarian/manifest'
|
2
|
+
require 'librarian/dependency'
|
3
|
+
require 'librarian/manifest_set'
|
4
|
+
|
5
|
+
# Override the lockfile parser, to allow '.' in package names.
|
6
|
+
module Librarian
|
7
|
+
class Lockfile
|
8
|
+
class Parser
|
9
|
+
|
10
|
+
def extract_and_parse_sources(lines)
|
11
|
+
sources = []
|
12
|
+
while source_type_names.include?(lines.first)
|
13
|
+
source = {}
|
14
|
+
source_type_name = lines.shift
|
15
|
+
source[:type] = source_type_names_map[source_type_name]
|
16
|
+
options = {}
|
17
|
+
while lines.first =~ /^ {2}([\w-]+):\s+(.+)$/
|
18
|
+
lines.shift
|
19
|
+
options[$1.to_sym] = $2
|
20
|
+
end
|
21
|
+
source[:options] = options
|
22
|
+
lines.shift # specs
|
23
|
+
manifests = {}
|
24
|
+
while lines.first =~ /^ {4}([.\w-]+) \((.*)\)$/
|
25
|
+
lines.shift
|
26
|
+
name = $1
|
27
|
+
manifests[name] = {:version => $2, :dependencies => {}}
|
28
|
+
while lines.first =~ /^ {6}([\w-]+) \((.*)\)$/
|
29
|
+
lines.shift
|
30
|
+
manifests[name][:dependencies][$1] = $2.split(/,\s*/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
source[:manifests] = manifests
|
34
|
+
sources << source
|
35
|
+
end
|
36
|
+
sources
|
37
|
+
end
|
38
|
+
|
39
|
+
def extract_and_parse_dependencies(lines, manifests_index)
|
40
|
+
dependencies = []
|
41
|
+
while lines.first =~ /^ {2}([.\w-]+)(?: \((.*)\))?$/
|
42
|
+
lines.shift
|
43
|
+
name, requirement = $1, $2.split(/,\s*/)
|
44
|
+
dependencies << Dependency.new(name, requirement, manifests_index[name].source)
|
45
|
+
end
|
46
|
+
dependencies
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "librarian/ansible"
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'librarian/ansible/extension'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'librarian/helpers'
|
2
|
+
|
3
|
+
require 'librarian/cli'
|
4
|
+
require 'librarian/ansible'
|
5
|
+
|
6
|
+
module Librarian
|
7
|
+
module Ansible
|
8
|
+
class Cli < Librarian::Cli
|
9
|
+
|
10
|
+
module Particularity
|
11
|
+
def root_module
|
12
|
+
Ansible
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
extend Particularity
|
17
|
+
|
18
|
+
source_root Pathname.new(__FILE__).dirname.join("templates")
|
19
|
+
|
20
|
+
def init
|
21
|
+
copy_file environment.specfile_name
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "install", "Resolves and installs all of the dependencies you specify."
|
25
|
+
option "quiet", :type => :boolean, :default => false
|
26
|
+
option "verbose", :type => :boolean, :default => false
|
27
|
+
option "line-numbers", :type => :boolean, :default => false
|
28
|
+
option "clean", :type => :boolean, :default => false
|
29
|
+
option "strip-dot-git", :type => :boolean
|
30
|
+
option "path", :type => :string
|
31
|
+
def install
|
32
|
+
ensure!
|
33
|
+
clean! if options["clean"]
|
34
|
+
if options.include?("strip-dot-git")
|
35
|
+
strip_dot_git_val = options["strip-dot-git"] ? "1" : nil
|
36
|
+
environment.config_db.local["install.strip-dot-git"] = strip_dot_git_val
|
37
|
+
end
|
38
|
+
if options.include?("path")
|
39
|
+
environment.config_db.local["path"] = options["path"]
|
40
|
+
end
|
41
|
+
resolve!
|
42
|
+
install!
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'librarian/dsl'
|
2
|
+
require 'librarian/ansible/source'
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
module Ansible
|
6
|
+
class Dsl < Librarian::Dsl
|
7
|
+
|
8
|
+
dependency :role
|
9
|
+
|
10
|
+
source :git => Source::Git
|
11
|
+
source :github => Source::Github
|
12
|
+
source :path => Source::Path
|
13
|
+
source :galaxy => Source::Galaxy
|
14
|
+
source :site => Source::Site
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "librarian/environment"
|
2
|
+
require "librarian/ansible/dsl"
|
3
|
+
require "librarian/ansible/source"
|
4
|
+
require "librarian/ansible/version"
|
5
|
+
|
6
|
+
require "ext/librarian/dsl/target"
|
7
|
+
|
8
|
+
module Librarian
|
9
|
+
module Ansible
|
10
|
+
class Environment < Environment
|
11
|
+
|
12
|
+
def adapter_name
|
13
|
+
"ansible"
|
14
|
+
end
|
15
|
+
|
16
|
+
def adapter_version
|
17
|
+
VERSION
|
18
|
+
end
|
19
|
+
|
20
|
+
def install_path
|
21
|
+
part = config_db["path"] || "librarian_roles"
|
22
|
+
project_path.join(part)
|
23
|
+
end
|
24
|
+
|
25
|
+
def config_keys
|
26
|
+
super + %w[
|
27
|
+
install.strip-dot-git
|
28
|
+
path
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
require 'librarian/manifest'
|
5
|
+
|
6
|
+
module Librarian
|
7
|
+
module Ansible
|
8
|
+
module ManifestReader
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def manifest_path(path)
|
12
|
+
path.join("meta/main.yml")
|
13
|
+
end
|
14
|
+
|
15
|
+
def read_manifest(name, manifest_path)
|
16
|
+
if [".yml", ".yaml"].include?(manifest_path.extname)
|
17
|
+
YAML.load(binread(manifest_path)).tap do |m|
|
18
|
+
m["dependencies"] ||= []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def manifest?(name, path)
|
24
|
+
path = Pathname.new(path)
|
25
|
+
!!manifest_path(path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_manifest(name, manifest_path)
|
29
|
+
manifest = read_manifest(name, manifest_path)
|
30
|
+
manifest["name"] == name
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
if File.respond_to?(:binread)
|
36
|
+
def binread(path)
|
37
|
+
File.binread(path)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
def binread(path)
|
41
|
+
File.read(path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "librarian/ansible/source/git"
|
2
|
+
require "faraday"
|
3
|
+
|
4
|
+
# Lookup an Ansible role in Galaxy API, using
|
5
|
+
# github_user and package name.
|
6
|
+
module Librarian
|
7
|
+
module Ansible
|
8
|
+
module Source
|
9
|
+
class Galaxy
|
10
|
+
|
11
|
+
@@galaxy_api = "https://galaxy.ansible.com/api/v1/"
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
def galaxy_api=(galaxy_api)
|
16
|
+
@@galaxy_api = galaxy_api
|
17
|
+
end
|
18
|
+
|
19
|
+
def lock_name
|
20
|
+
Git.lock_name
|
21
|
+
end
|
22
|
+
|
23
|
+
def from_lock_options(environment, options)
|
24
|
+
Git.from_lock_options(environment, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def from_spec_args(environment, uri, options)
|
28
|
+
Git.from_spec_args(environment, github_url(uri), options)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def github_url(uri)
|
34
|
+
username, name = uri.split(".")
|
35
|
+
|
36
|
+
conn = Faraday.new(:url => @@galaxy_api)
|
37
|
+
|
38
|
+
response = conn.get("#{@@galaxy_api}/roles/?name=#{name}&format=json")
|
39
|
+
|
40
|
+
if response.status != 200
|
41
|
+
raise Error, "Could not read package from galaxy API."
|
42
|
+
else
|
43
|
+
package = JSON.parse(response.body)['results'].find do |r|
|
44
|
+
r['summary_fields']['owner']['username'] == username &&
|
45
|
+
r['name'] == name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
"https://github.com/#{package['github_user']}/#{package['github_repo']}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'librarian/source/git'
|
2
|
+
require 'librarian/ansible/source/local'
|
3
|
+
|
4
|
+
# Install an ansible role based on git url.
|
5
|
+
module Librarian
|
6
|
+
module Ansible
|
7
|
+
module Source
|
8
|
+
class Git < Librarian::Source::Git
|
9
|
+
include Local
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def install_perform_step_copy!(found_path, install_path)
|
14
|
+
debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" }
|
15
|
+
FileUtils.cp_r(found_path, install_path)
|
16
|
+
|
17
|
+
if environment.config_db["install.strip-dot-git"] == "1"
|
18
|
+
dot_git = install_path.join(".git")
|
19
|
+
dot_git.rmtree if dot_git.directory?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'librarian/ansible/source/git'
|
2
|
+
|
3
|
+
# Install an ansible role based on github_user/github_repo
|
4
|
+
# format.
|
5
|
+
module Librarian
|
6
|
+
module Ansible
|
7
|
+
module Source
|
8
|
+
class Github
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def lock_name
|
13
|
+
Git.lock_name
|
14
|
+
end
|
15
|
+
|
16
|
+
def from_lock_options(environment, options)
|
17
|
+
Git.from_lock_options(environment, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def from_spec_args(environment, uri, options)
|
21
|
+
Git.from_spec_args(environment, "https://github.com/#{uri}", options)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'librarian/ansible/manifest_reader'
|
2
|
+
|
3
|
+
# Install a local role.
|
4
|
+
module Librarian
|
5
|
+
module Ansible
|
6
|
+
module Source
|
7
|
+
module Local
|
8
|
+
|
9
|
+
def install!(manifest)
|
10
|
+
manifest.source == self or raise ArgumentError
|
11
|
+
|
12
|
+
info { "Installing #{manifest.name} (#{manifest.version})" }
|
13
|
+
|
14
|
+
debug { "Installing #{manifest}" }
|
15
|
+
|
16
|
+
name, version = manifest.name, manifest.version
|
17
|
+
found_path = found_path(name)
|
18
|
+
|
19
|
+
install_path = environment.install_path.join(name)
|
20
|
+
if install_path.exist?
|
21
|
+
debug { "Deleting #{relative_path_to(install_path)}" }
|
22
|
+
install_path.rmtree
|
23
|
+
end
|
24
|
+
|
25
|
+
install_perform_step_copy!(found_path, install_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def fetch_version(name, extra)
|
29
|
+
manifest_data(name)["version"] || "0.0.0"
|
30
|
+
end
|
31
|
+
|
32
|
+
def fetch_dependencies(name, version, extra)
|
33
|
+
manifest_data(name)["dependencies"]
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def install_perform_step_copy!(found_path, install_path)
|
39
|
+
debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" }
|
40
|
+
FileUtils.mkdir_p(install_path)
|
41
|
+
FileUtils.cp_r(filter_path(found_path), install_path)
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter_path(path)
|
45
|
+
Dir.glob("#{path}/*").reject { |e| e == environment.install_path.to_s }
|
46
|
+
end
|
47
|
+
|
48
|
+
def manifest_data(name)
|
49
|
+
@manifest_data ||= { }
|
50
|
+
@manifest_data[name] ||= fetch_manifest_data(name)
|
51
|
+
end
|
52
|
+
|
53
|
+
def fetch_manifest_data(name)
|
54
|
+
expect_manifest!(name)
|
55
|
+
|
56
|
+
found_path = found_path(name)
|
57
|
+
manifest_path = ManifestReader.manifest_path(found_path)
|
58
|
+
ManifestReader.read_manifest(name, manifest_path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def manifest?(name, path)
|
62
|
+
ManifestReader.manifest?(name, path)
|
63
|
+
end
|
64
|
+
|
65
|
+
def expect_manifest!(name)
|
66
|
+
found_path = found_path(name)
|
67
|
+
return if found_path && ManifestReader.manifest_path(found_path)
|
68
|
+
|
69
|
+
raise Error, "No metadata file found for #{name} from #{self}! If this should be an ansible role, you might consider contributing a metadata file upstream or forking the ansible role to add your own metadata file."
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'librarian/source/path'
|
2
|
+
require 'librarian/ansible/source/local'
|
3
|
+
|
4
|
+
# Install local dependency based on
|
5
|
+
# file path.
|
6
|
+
module Librarian
|
7
|
+
module Ansible
|
8
|
+
module Source
|
9
|
+
class Path < Librarian::Source::Path
|
10
|
+
include Local
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'librarian/source/path'
|
2
|
+
require 'librarian/ansible/source/git'
|
3
|
+
require 'librarian/ansible/source/galaxy'
|
4
|
+
|
5
|
+
# Set the Galaxy API url, using the
|
6
|
+
# site directive.
|
7
|
+
module Librarian
|
8
|
+
module Ansible
|
9
|
+
module Source
|
10
|
+
class Site
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def lock_name
|
15
|
+
Git.lock_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def from_lock_options(environment, options)
|
19
|
+
Git.from_lock_options(environment, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def from_spec_args(environment, uri, options)
|
23
|
+
Galaxy.galaxy_api = uri
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'librarian/ansible/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "librarian-ansible"
|
8
|
+
gem.version = Librarian::Ansible::VERSION
|
9
|
+
gem.authors = ["Jay Feldblum"]
|
10
|
+
gem.email = ["y_feldblum@yahoo.com"]
|
11
|
+
gem.summary = %q{A Bundler for your Ansible roles.}
|
12
|
+
gem.description = %q{A Bundler for your Ansible roles.}
|
13
|
+
gem.homepage = ""
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_dependency "librarian", "~> 0.1.0"
|
22
|
+
gem.add_dependency "faraday"
|
23
|
+
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
gem.add_development_dependency "rspec"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: librarian-ansible
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jay Feldblum
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: librarian
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A Bundler for your Ansible roles.
|
70
|
+
email:
|
71
|
+
- y_feldblum@yahoo.com
|
72
|
+
executables:
|
73
|
+
- librarian-ansible
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/librarian-ansible
|
83
|
+
- lib/ext/librarian/dsl/target.rb
|
84
|
+
- lib/ext/librarian/lockfile/parser.rb
|
85
|
+
- lib/librarian-ansible.rb
|
86
|
+
- lib/librarian/ansible.rb
|
87
|
+
- lib/librarian/ansible/cli.rb
|
88
|
+
- lib/librarian/ansible/dsl.rb
|
89
|
+
- lib/librarian/ansible/environment.rb
|
90
|
+
- lib/librarian/ansible/extension.rb
|
91
|
+
- lib/librarian/ansible/manifest_reader.rb
|
92
|
+
- lib/librarian/ansible/source.rb
|
93
|
+
- lib/librarian/ansible/source/galaxy.rb
|
94
|
+
- lib/librarian/ansible/source/git.rb
|
95
|
+
- lib/librarian/ansible/source/github.rb
|
96
|
+
- lib/librarian/ansible/source/local.rb
|
97
|
+
- lib/librarian/ansible/source/path.rb
|
98
|
+
- lib/librarian/ansible/source/site.rb
|
99
|
+
- lib/librarian/ansible/templates/Ansiblefile
|
100
|
+
- lib/librarian/ansible/version.rb
|
101
|
+
- librarian-ansible.gemspec
|
102
|
+
homepage: ''
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: A Bundler for your Ansible roles.
|
126
|
+
test_files: []
|