Class: PoolParty::Provisioner::Master
Instance Method Summary
collapse
#configure, configure, #configure_string, #custom_configure_tasks, #custom_install_tasks, #default_configure_tasks, #default_install_tasks, #get_puppet_packages_for, install, #install, #install_string, #installer_for, installers, #loaded, #process_configure!, #process_install!, #setup_runner, #template_directory, #write_configure_file, #write_install_file
#full_keypair_path, #instances, #keypair_path, #keypair_paths, #new_keypair_path, #number_of_resources, #parent, #possible_keypair_basenames, #set_parent
included
Constructor Details
#initialize(cloud = self, os = :ubuntu) ⇒ Master
Returns a new instance of Master.
5
6
7
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 5
def initialize(cloud=self, os=:ubuntu)
super(cloud.master, cloud)
end
|
Instance Method Details
29
30
31
32
33
34
35
36
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 29
def configure_tasks
[
create_local_node,
move_templates,
create_poolparty_manifest,
restart_puppetd
]
end
|
#create_local_hosts_entry ⇒ Object
42
43
44
45
46
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 42
def create_local_hosts_entry
<<-EOS
if [ -z "grep -v '#' /etc/hosts | grep 'puppet'" ]; then echo '#{@master_ip} puppet master' >> /etc/hosts; fi
EOS
end
|
#create_local_node ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 84
def create_local_node
str = <<-EOS
node default {
include poolparty
}
EOS
@cloud.list_of_running_instances.each do |ri|
str << <<-EOS
node "#{ri.name}" inherits default {}
EOS
end
"echo '#{str}' > /etc/puppet/manifests/nodes/nodes.pp"
end
|
#create_poolparty_manifest ⇒ Object
105
106
107
108
109
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 105
def create_poolparty_manifest
<<-EOS
mv #{Base.remote_storage_path}/#{Base.tmp_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
EOS
end
|
13
14
15
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 13
def error
raise RemoteException.new(:could_not_install, "Your cloud does not have a master")
end
|
#install_puppet_master ⇒ Object
38
39
40
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 38
def install_puppet_master
"#{installer_for(@os)} #{get_puppet_packages_for(@os)}"
end
|
#install_tasks ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 17
def install_tasks
[
install_puppet_master,
create_local_hosts_entry,
setup_basic_structure,
setup_configs,
setup_fileserver,
setup_autosigning,
start_puppetmaster
] << configure_tasks
end
|
#move_templates ⇒ Object
98
99
100
101
102
103
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 98
def move_templates
<<-EOS
mkdir -p #{Base.template_path}
mv #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path}
EOS
end
|
#restart_puppetd ⇒ Object
&& puppetrun --host 127.0.0.1
115
116
117
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 115
def restart_puppetd end
|
#setup_autosigning ⇒ Object
Change this eventually for better security supportsetup_fileserver
78
79
80
81
82
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 78
def setup_autosigning
<<-EOS
echo "*" > /etc/puppet/autosign.conf
EOS
end
|
#setup_basic_structure ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 48
def setup_basic_structure
<<-EOS
puppetmasterd --mkusers
mkdir -p #{Base.remote_storage_path}
echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp
echo "import 'classes/*.pp'" >> /etc/puppet/manifests/site.pp
mkdir -p /etc/puppet/manifests/nodes
mkdir -p /etc/puppet/manifests/classes
mv #{Base.remote_storage_path}/#{Base.tmp_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
EOS
end
|
#setup_configs ⇒ Object
60
61
62
63
64
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 60
def setup_configs
<<-EOS
echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
EOS
end
|
#setup_fileserver ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 66
def setup_fileserver
<<-EOS
echo "
[files]
path #{Base.remote_storage_path}/#{Base.tmp_path}
allow *" > /etc/puppet/fileserver.conf
mkdir -p /var/poolparty/facts
mkdir -p /var/poolparty/files
mkdir -p /etc/poolparty
EOS
end
|
#start_puppetmaster ⇒ Object
111
112
113
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 111
def start_puppetmaster
"puppetmasterd && puppetd --listen"
end
|
#valid? ⇒ Boolean
9
10
11
|
# File 'lib/poolparty/helpers/provisioners/master.rb', line 9
def valid?
!(@cloud.nil? || @cloud.master.nil?)
end
|