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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99111d82efeeebbbfc1e737f21c142b8d032c24e32ac41d91b66d47c80a2201c
4
- data.tar.gz: e542a73b031675176749476dd06d9cc7a94ac5e5b31989321f9b5f94ad027710
3
+ metadata.gz: a44cb786491c3627ecfb6d10983b1bdd75267524637b6fefe75d464d520c3f2e
4
+ data.tar.gz: 67510561106ad65ecc8cd476bff271fee1cfc944761bb09588edba6bdbd22efd
5
5
  SHA512:
6
- metadata.gz: 0b667cfc048d8fc7e5fd661db7efbb19c21df2bf4c21e7c6e70041df2ec8045c7ae26fdd3d1beb5e09ab8a8efd1aaf30c259009940ba27498c9f99e1f560507a
7
- data.tar.gz: 2a50d6c9f5aea2dac0374580603fb55785e944097fcac765fadbd940b9a69e7242c308693600a0abf68f991c75ae23f5a70e4b188fa6e3ac73d951601f7ccade
6
+ metadata.gz: b7131df4601d7268a08bc4533878565e3b0c2ca8482cbaea46385098a0fcad878654b11f6aa22d884f4e977dc3eb8c605a5b1fe28cb73c9f65858b073c61cc26
7
+ data.tar.gz: 813f605397086790abcb97ee31158dd24b492d58734b7bc62b1477edf3ba9c937fee7ef4441620cb843d0caa0c4699bf7c4b035cb59612c56a079f5a1e415983
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.0
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` where each `main.yml` file
5
- is represented by a section (`defaults:`, `vars:`, `tasks:` etc.)
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
- ```shell
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
- `ansible-make-role` only generates up-to-date files unless the --force option
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 the .gitignore file will be overwritten
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`
@@ -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", "~> 1.17"
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
 
@@ -44,7 +44,7 @@ end
44
44
 
45
45
  role_dirs = args
46
46
  for roles_dir in roles_dirs
47
- role_dirs += Dir["#{roles_dir}/*"].select { |d| File.directory?(d) }
47
+ role_dirs += Dir["#{roles_dir}/**/role.yml"].map { |f| File.dirname(f) }
48
48
  end
49
49
 
50
50
  if role_dirs.empty?
@@ -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
- files = compile_role(role_file, role_dir)
27
- if git
28
- git_file = "#{role_dir}/.gitignore"
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 "Not a role directory: #{role_dir}"
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
- generated_files = []
98
- (sections.to_a + [["meta", meta]]).each { |section, lines|
99
- next if lines.empty? && section != "meta"
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
- generated_files
107
+ file
108
+ }.compact
112
109
  end
113
110
 
114
111
  # Unindent lines by the indentation of the first non-comment and non-blank
@@ -1,3 +1,3 @@
1
1
  module AnsibleMakeRole
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.10"
3
3
  end
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.6
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: 2020-03-15 00:00:00.000000000 Z
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: '1.17'
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: '1.17'
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.0.1
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