Class: Vagrant::Hivemind::Util::Ansible
- Inherits:
-
Object
- Object
- Vagrant::Hivemind::Util::Ansible
- Defined in:
- lib/vagrant/hivemind/util.rb
Class Method Summary collapse
- .generate_hosts_file(hosts = {}, path = Pathname.new(Dir.pwd)) ⇒ Object
- .read_from(path = Pathname.new(Dir.pwd)) ⇒ Object
Class Method Details
.generate_hosts_file(hosts = {}, path = Pathname.new(Dir.pwd)) ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/vagrant/hivemind/util.rb', line 193 def self.generate_hosts_file(hosts = {}, path = Pathname.new(Dir.pwd)) datetime_now = DateTime.now.strftime "%F %T %p" b = binding template_string = "" File.open(File.("../../../../templates/ansible.hosts.erb", __FILE__), "r") do |f| template_string = f.read end template = ERB.new template_string template_result = template.result(b) ansible_hosts_file = get_ansible_hosts_file_from_path path File.open(ansible_hosts_file, "w+") do |f| f.write(template_result) end end |
.read_from(path = Pathname.new(Dir.pwd)) ⇒ Object
211 212 213 214 215 216 217 218 |
# File 'lib/vagrant/hivemind/util.rb', line 211 def self.read_from(path = Pathname.new(Dir.pwd)) ansible_hosts_file = get_ansible_hosts_file_from_path path ansible_hosts = "" File.open() do |f| ansible_hosts = f.read end ansible_hosts end |