ansible_make_role 0.7.6 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +11 -9
- data/ansible_make_role.gemspec +1 -1
- data/exe/ansible-make-role +1 -1
- data/lib/ansible_make_role.rb +14 -17
- data/lib/ansible_make_role/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a44cb786491c3627ecfb6d10983b1bdd75267524637b6fefe75d464d520c3f2e
|
4
|
+
data.tar.gz: 67510561106ad65ecc8cd476bff271fee1cfc944761bb09588edba6bdbd22efd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7131df4601d7268a08bc4533878565e3b0c2ca8482cbaea46385098a0fcad878654b11f6aa22d884f4e977dc3eb8c605a5b1fe28cb73c9f65858b073c61cc26
|
7
|
+
data.tar.gz: 813f605397086790abcb97ee31158dd24b492d58734b7bc62b1477edf3ba9c937fee7ef4441620cb843d0caa0c4699bf7c4b035cb59612c56a079f5a1e415983
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.7.1
|
data/README.md
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# ansible-make-role
|
2
2
|
|
3
3
|
Pre-compiler that turns a single-file role definition into Ansible role files.
|
4
|
-
The `role.yml` file combines the Ansible `main.yml`
|
5
|
-
|
4
|
+
The single-file `role.yml` file combines the Ansible `main.yml` files from the
|
5
|
+
`defaults`, `vars`, `tasks`, and `meta` subdirectories with a YAML top-level
|
6
|
+
section for each file (`defaults:`, `vars:`, `tasks:` etc.)
|
6
7
|
|
7
8
|
## Usage
|
8
9
|
|
9
|
-
```
|
10
|
+
```
|
10
11
|
ansible-make-role -c|--clean -f|--force -g|--git -r|--roles=DIR -v|--verbose --version DIR...
|
11
12
|
```
|
12
13
|
|
13
14
|
`ansible-make-role` expects a `role.yml` file in each of the given directories
|
14
15
|
and generates an Ansible role in it. Existing `main.yml` files will be
|
15
|
-
overwritten or removed but other files won't be touched
|
16
|
-
|
17
|
-
|
18
|
-
is used
|
16
|
+
overwritten or removed but other files won't be touched. `ansible-make-role`
|
17
|
+
search subdirectories of `./roles` if no dirctories was given on the command
|
18
|
+
line
|
19
19
|
|
20
20
|
## Description
|
21
21
|
|
@@ -59,10 +59,12 @@ handlers: # Goes to handlers/main.yml"
|
|
59
59
|
Clean the project by removing autogenerated files
|
60
60
|
|
61
61
|
`-f, --force`
|
62
|
-
Re-generate all files even if not needed
|
62
|
+
Re-generate all files even if not needed. Useful if you forgot a
|
63
|
+
`--git` option
|
63
64
|
|
64
65
|
`-g, --git`
|
65
|
-
Also handle per-role .gitignore files. Note that
|
66
|
+
Also handle per-role .gitignore files. Note that existing .gitignore
|
67
|
+
files are overwritten
|
66
68
|
|
67
69
|
`-r, --roles=DIR`
|
68
70
|
Use DIR instead of default `./roles`
|
data/ansible_make_role.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
39
39
|
spec.require_paths = ["lib"]
|
40
40
|
|
41
|
-
spec.add_development_dependency "bundler", "~>
|
41
|
+
spec.add_development_dependency "bundler", "~> 2.2.10"
|
42
42
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
43
43
|
spec.add_development_dependency "rspec", "~> 3.0"
|
44
44
|
|
data/exe/ansible-make-role
CHANGED
data/lib/ansible_make_role.rb
CHANGED
@@ -19,28 +19,25 @@ module AnsibleMakeRole
|
|
19
19
|
def self.git=(value) @git = value end
|
20
20
|
|
21
21
|
def self.make(role_dir)
|
22
|
+
changed = false
|
22
23
|
wrap_system_call_error {
|
23
24
|
role_file = "#{role_dir}/#{ROLE_FILE_NAME}"
|
24
25
|
meta_file = "#{role_dir}/meta/main.yml"
|
26
|
+
git_file = "#{role_dir}/.gitignore"
|
25
27
|
if force || !File.exist?(meta_file) || File.mtime(role_file) > File.mtime(meta_file)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
FileUtils.rm_f(git_file)
|
30
|
-
if !files.empty?
|
31
|
-
lines = files.map { |f| "./" + f.split("/")[-2..-1].join("/") + "\n" }.join
|
32
|
-
IO.write(git_file, lines)
|
33
|
-
end
|
28
|
+
if !compile_role(role_file, role_dir).empty?
|
29
|
+
IO.write(git_file, "*/main.yml\n") if git
|
30
|
+
changed = true
|
34
31
|
end
|
35
|
-
true
|
36
32
|
end
|
37
33
|
}
|
34
|
+
return changed
|
38
35
|
end
|
39
36
|
|
40
37
|
def self.clean(role_dir)
|
41
38
|
changed = false
|
42
39
|
wrap_system_call_error {
|
43
|
-
File.exists?("#{role_dir}/#{ROLE_FILE_NAME}") or raise Error
|
40
|
+
File.exists?("#{role_dir}/#{ROLE_FILE_NAME}") or raise Error.new("Not a role directory: #{role_dir}")
|
44
41
|
for file in Dir["#{role_dir}/*/main.yml"]
|
45
42
|
FileUtils.rm(file)
|
46
43
|
dir = File.dirname(file)
|
@@ -94,21 +91,21 @@ private
|
|
94
91
|
end
|
95
92
|
}
|
96
93
|
|
97
|
-
|
98
|
-
|
99
|
-
|
94
|
+
if meta.all? { |l| l =~ /^\s*$/ }
|
95
|
+
meta = ["dependencies: []"]
|
96
|
+
end
|
97
|
+
|
98
|
+
(sections.to_a + [["meta", meta]]).map { |section, lines|
|
100
99
|
next if lines.all? { |l| l =~ /^\s*$/ }
|
101
100
|
dir = "#{target}/#{section}"
|
102
101
|
file = "#{dir}/main.yml"
|
103
|
-
generated_files << file
|
104
|
-
|
105
102
|
FileUtils.mkdir_p(dir)
|
106
103
|
File.open(file, "w") { |f|
|
107
104
|
f.puts "---" if section != "meta"
|
108
105
|
unindent(lines).each { |l| f.puts l }
|
109
106
|
}
|
110
|
-
|
111
|
-
|
107
|
+
file
|
108
|
+
}.compact
|
112
109
|
end
|
113
110
|
|
114
111
|
# Unindent lines by the indentation of the first non-comment and non-blank
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansible_make_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.10
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
130
|
+
rubygems_version: 3.1.4
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Make Ansible role from make.yml file
|