Module: MasterManipulator::Site
- Included in:
- Beaker::TestCase
- Defined in:
- lib/master_manipulator/site.rb
Instance Method Summary collapse
-
#create_site_pp(master_host, opts = {}) ⇒ String
Create a site.pp file with file bucket enabled.
-
#get_manifests_path(master_host, opts = {}) ⇒ String
Get the location of an environment’s manifests path; defaults to production environment.
-
#get_site_pp_path(master_host, opts = {}) ⇒ String
Get the path to a given environment’s site.pp; defaults to production environment.
-
#inject_site_pp(master_host, site_pp_path, manifest) ⇒ Object
Inject a site.pp manifest onto a master.
-
#set_perms_on_remote(master_host, path, mode, opts = {}) ⇒ Object
Set mode, owner and group on a remote path.
Instance Method Details
#create_site_pp(master_host, opts = {}) ⇒ String
Create a site.pp file with file bucket enabled. Also, allow the creation of a custom node definition or use the default node definition.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/master_manipulator/site.rb', line 49 def create_site_pp(master_host, opts = {}) opts[:manifest] ||= '' opts[:node_def_name] ||= 'default' master_certname = on(master_host, puppet('config print certname')).stdout.rstrip default_def = <<-MANIFEST node default { } MANIFEST node_def = <<-MANIFEST node #{opts[:node_def_name]} { #{opts[:manifest]} } MANIFEST if opts[:node_def_name] != 'default' node_def = "#{default_def}\n#{node_def}" end site_pp = <<-MANIFEST filebucket { 'main': server => '#{master_certname}', path => false, } File { backup => 'main' } #{node_def} MANIFEST return site_pp end |
#get_manifests_path(master_host, opts = {}) ⇒ String
Get the location of an environment’s manifests path; defaults to production environment.
13 14 15 16 17 18 |
# File 'lib/master_manipulator/site.rb', line 13 def get_manifests_path(master_host, opts = {}) opts[:env] ||= 'production' environment_base_path = on(master_host, puppet('config print environmentpath')).stdout.rstrip return File.join(environment_base_path, opts[:env], 'manifests') end |
#get_site_pp_path(master_host, opts = {}) ⇒ String
Get the path to a given environment’s site.pp; defaults to production environment.
29 30 31 32 33 |
# File 'lib/master_manipulator/site.rb', line 29 def get_site_pp_path(master_host, opts = {}) opts[:env] ||= 'production' return File.join(get_manifests_path(master_host, opts), 'site.pp') end |
#inject_site_pp(master_host, site_pp_path, manifest) ⇒ Object
Inject a site.pp manifest onto a master.
114 115 116 117 118 119 |
# File 'lib/master_manipulator/site.rb', line 114 def inject_site_pp(master_host, site_pp_path, manifest) site_pp_dir = File.dirname(site_pp_path) create_remote_file(master_host, site_pp_path, manifest) set_perms_on_remote(master_host, site_pp_dir, '0744') end |
#set_perms_on_remote(master_host, path, mode, opts = {}) ⇒ Object
Set mode, owner and group on a remote path.
99 100 101 102 103 104 105 |
# File 'lib/master_manipulator/site.rb', line 99 def set_perms_on_remote(master_host, path, mode, opts = {}) opts[:owner] ||= on(master_host, puppet('config print user')).stdout.rstrip opts[:group] ||= on(master_host, puppet('config print group')).stdout.rstrip on(master_host, "chmod -Rv #{mode} #{path}") on(master_host, "chown -Rv #{opts[:owner]}:#{opts[:group]} #{path}") end |