Module: AnsibleMakeRole
- Defined in:
- lib/ansible_make_role.rb,
lib/ansible_make_role/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- ROLE_FILE_NAME =
"role.yml"- DEFAULT_FORCE_FLAG =
false- DEFAULT_GIT_FLAG =
false- VERSION =
"0.7.8"
Class Method Summary collapse
- .clean(role_dir) ⇒ Object
- .force ⇒ Object
- .force=(value) ⇒ Object
- .git ⇒ Object
- .git=(value) ⇒ Object
- .make(role_dir) ⇒ Object
Class Method Details
.clean(role_dir) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ansible_make_role.rb', line 37 def self.clean(role_dir) changed = false wrap_system_call_error { File.exists?("#{role_dir}/#{ROLE_FILE_NAME}") or raise Error.new("Not a role directory: #{role_dir}") for file in Dir["#{role_dir}/*/main.yml"] FileUtils.rm(file) dir = File.dirname(file) FileUtils.rmdir(dir) if File.empty?(dir) changed = true end git_file = "#{role_dir}/.gitignore" if git && File.exist?(git_file) FileUtils.rm(git_file) changed = true end } return changed end |
.force ⇒ Object
14 |
# File 'lib/ansible_make_role.rb', line 14 def self.force() @force end |
.force=(value) ⇒ Object
15 |
# File 'lib/ansible_make_role.rb', line 15 def self.force=(value) @force = value end |
.git ⇒ Object
18 |
# File 'lib/ansible_make_role.rb', line 18 def self.git() @git end |
.git=(value) ⇒ Object
19 |
# File 'lib/ansible_make_role.rb', line 19 def self.git=(value) @git = value end |
.make(role_dir) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ansible_make_role.rb', line 21 def self.make(role_dir) changed = false wrap_system_call_error { role_file = "#{role_dir}/#{ROLE_FILE_NAME}" = "#{role_dir}/meta/main.yml" git_file = "#{role_dir}/.gitignore" if force || !File.exist?() || File.mtime(role_file) > File.mtime() if !compile_role(role_file, role_dir).empty? IO.write(git_file, "*/main.yml\n") if git changed = true end end } return changed end |