Class: Hyrb::Models::AnsibleSite
- Inherits:
-
Struct
- Object
- Hyrb::Model
- Struct
- Hyrb::Models::AnsibleSite
- Defined in:
- lib/hyrb/models/ansible_site.rb
Instance Attribute Summary collapse
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#vars_prompt ⇒ Object
Returns the value of attribute vars_prompt.
Attributes inherited from Hyrb::Model
Instance Method Summary collapse
- #deserialize(data) ⇒ Object
-
#initialize(project, environment) ⇒ AnsibleSite
constructor
A new instance of AnsibleSite.
- #load_config_file ⇒ Object
- #serialize(data) ⇒ Object
Methods inherited from Struct
#[], #[]=, define_keys, keys
Methods inherited from Hyrb::Model
Constructor Details
#initialize(project, environment) ⇒ AnsibleSite
Returns a new instance of AnsibleSite.
17 18 19 20 21 22 23 24 25 |
# File 'lib/hyrb/models/ansible_site.rb', line 17 def initialize(project, environment) @path = File.join(project.ansible_path, environment.label) @raw_playbook = load_config_file[0] @data = deserialize(@raw_playbook) @vars_prompt = @raw_playbook["vars_prompt"] @roles = @raw_playbook["roles"] @hosts = @raw_playbook["hosts"] end |
Instance Attribute Details
#hosts ⇒ Object
Returns the value of attribute hosts.
4 5 6 |
# File 'lib/hyrb/models/ansible_site.rb', line 4 def hosts @hosts end |
#roles ⇒ Object
Returns the value of attribute roles.
4 5 6 |
# File 'lib/hyrb/models/ansible_site.rb', line 4 def roles @roles end |
#vars_prompt ⇒ Object
Returns the value of attribute vars_prompt.
4 5 6 |
# File 'lib/hyrb/models/ansible_site.rb', line 4 def vars_prompt @vars_prompt end |
Instance Method Details
#deserialize(data) ⇒ Object
41 42 43 |
# File 'lib/hyrb/models/ansible_site.rb', line 41 def deserialize(data) data["vars"].reduce(Hash.new, :merge) end |
#load_config_file ⇒ Object
27 28 29 |
# File 'lib/hyrb/models/ansible_site.rb', line 27 def load_config_file super || YAML.load_file("#{TEMPLATE_PATH}/ansible/site.yml") end |
#serialize(data) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/hyrb/models/ansible_site.rb', line 31 def serialize(data) # yuck, this is no longer a pure fn @raw_playbook["vars_prompt"] = vars_prompt @raw_playbook["roles"] = roles @raw_playbook["hosts"] = hosts @raw_playbook["vars"] = @data.map { |k, v| {k.to_s => v} } [@raw_playbook] end |