class Hyrb::Models::AnsibleHost

Attributes

ansible_ssh_host[RW]
ansible_ssh_user[RW]
host[RW]

Public Class Methods

new(project, environment) click to toggle source
# File lib/hyrb/models/ansible_host.rb, line 6
def initialize(project, environment)
  @path = File.join(project.ansible_path, "hosts")
  @data = deserialize(load_config_file) || []
  self.host = environment.label
  self.ansible_ssh_host = environment.host
  # TODO: this should be different on eg EC2
  self.ansible_ssh_user = "root"
end

Public Instance Methods

serialize(data) click to toggle source
# File lib/hyrb/models/ansible_host.rb, line 15
def serialize(data)
  # remove the host that we're working on
  data.reject! { |h| h["host"] == host }
  data += [{
    host: host,
    vars: {
      ansible_ssh_host: ansible_ssh_host,
      ansible_ssh_user: ansible_ssh_user,
    }.stringify_keys,
  }.stringify_keys]
end