Class: LogicalConstruct::GroundControl::Provision

Inherits:
Mattock::Tasklib
  • Object
show all
Includes:
Mattock::CommandLineDSL
Defined in:
lib/logical-construct/ground-control/provision.rb

Defined Under Namespace

Classes: WebConfigure

Instance Method Summary collapse

Instance Method Details

#default_configuration(core) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/logical-construct/ground-control/provision.rb', line 110

def default_configuration(core)
  core.copy_settings_to(self)
  super
  self.cookbooks.path = "cookbooks"
  self.secret_data.path = "data-bags/secret"
  self.normal_data.path = "data-bags"
end

#defineObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/logical-construct/ground-control/provision.rb', line 145

def define
  in_namespace do
    directory marshalling_path

    task :collect, [:ipaddr, :role] do |task, args|
      self.target_address = args[:ipaddr]
      unless args[:role].nil?
        self.node_attribs["run_list"] = roles[args[:role]]
      end
      self.json_attribs = JSON.pretty_generate(node_attribs)
      resolutions["chef_config:json_attribs"] ||= json_attribs
    end

    file secret_data.tarball_path => [marshalling_path] + secret_data.file_list do
      cmd("tar", "--exclude **/*.sw?", "-czf", secret_data.tarball_path, secret_data.path).must_succeed!
    end

    file normal_data.tarball_path => [marshalling_path] + normal_data.file_list do
      cmd("tar",
          "--exclude **/*.sw?",
          "--exclude #{secret_data.path}",
          "-czf", normal_data.tarball_path, normal_data.path).must_succeed!
    end

    file cookbooks.tarball_path => [marshalling_path] + cookbooks.file_list do
      cmd("tar", "--exclude .git", "--exclude **/*.sw?", "-czf", cookbooks.tarball_path, cookbooks.path).must_succeed!
    end

    manifest = LogicalConstruct::GenerateManifest.new(self, :manifest => [cookbooks.tarball_path, :collect]) do |manifest|
      manifest.receiving_name = "configuration:Manifest"
    end

    WebConfigure.new(:web_configure => [:collect, :manifest, cookbooks.tarball_path]) do |task|
      self.proxy_settings_to(task)
      task.target_address = proxy_value.target_address
    end
  end

  task root_task, [:ipaddr] => self[:web_configure]
end

#resolve_configurationObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/logical-construct/ground-control/provision.rb', line 118

def resolve_configuration
  super
  self.json_attribs_path ||= File::join(marshalling_path, "node.json")

  self.cookbooks.file_list ||= Rake::FileList[cookbooks.path + "/**/*"].exclude(%r{/[.]git/}).exclude(%r{[.]sw[.]$})
  self.secret_data.file_list ||= Rake::FileList[secret_data.path + "/**/*"].exclude(%r{[.]sw[.]$})
  self.normal_data.file_list ||=
    Rake::FileList[normal_data.path + "/**/*"].exclude(%r{^#{secret_data.path}}).exclude(%r{[.]sw[.]$})

  self.cookbooks.tarball_path ||= File::join(marshalling_path, "cookbooks.tgz")
  self.secret_data.tarball_path ||= File::join(marshalling_path, "secret_data_bags.tgz")
  self.normal_data.tarball_path ||= File::join(marshalling_path, "normal_data_bags.tgz")

  resolutions["chef_config:cookbook_tarball"] ||= proc do
    File::open(cookbooks.tarball_path, "rb")
  end

  resolutions["chef_config:secret_data_tarball"] ||= proc do
    File::open(secret_data.tarball_path, "rb")
  end

  resolutions["chef_config:normal_data_tarball"] ||= proc do
    File::open(normal_data.tarball_path, "rb")
  end
end