Module: Chef::Sugar::DSL

Defined in:
lib/chef/sugar/ip.rb,
lib/chef/sugar/ruby.rb,
lib/chef/sugar/cloud.rb,
lib/chef/sugar/shell.rb,
lib/chef/sugar/filters.rb,
lib/chef/sugar/vagrant.rb,
lib/chef/sugar/data_bag.rb,
lib/chef/sugar/platform.rb,
lib/chef/sugar/architecture.rb,
lib/chef/sugar/platform_family.rb

Instance Method Summary collapse

Instance Method Details

#_32_bit?Boolean Also known as: i386?

Returns:

  • (Boolean)

See Also:



49
# File 'lib/chef/sugar/architecture.rb', line 49

def _32_bit?; Chef::Sugar::Architecture._32_bit?(node); end

#_64_bit?Boolean

Returns:

  • (Boolean)

See Also:



46
# File 'lib/chef/sugar/architecture.rb', line 46

def _64_bit?; Chef::Sugar::Architecture._64_bit?(node); end

#after(identifier, &block) ⇒ Object

Dynamically insert resources after an existing resource in the resource_collection.

after 'service[apache2]' do
  template '/etc/apache2/thing.conf' do
    source '...'
  end
end

Examples:

Write a custom template after the apache2 service actions

are run

Parameters:

  • identifier (String)

    the resource[name] identifier string



142
143
144
# File 'lib/chef/sugar/filters.rb', line 142

def after(identifier, &block)
  Chef::Sugar::Filters::Injector.new(self, identifier, :after).evaluate(&block)
end

#azure?Boolean

Returns:

  • (Boolean)

See Also:



159
# File 'lib/chef/sugar/cloud.rb', line 159

def azure?; Chef::Sugar::Cloud.azure?(node); end

#before(identifier, &block) ⇒ Object

Dynamically insert resources before an existing resource in the resource_collection.

before 'service[apache2]' do
  template '/etc/apache2/thing.conf' do
    source '...'
  end
end

Examples:

Write a custom template before the apache2 service actions

are run

Parameters:

  • identifier (String)

    the resource[name] identifier string



122
123
124
# File 'lib/chef/sugar/filters.rb', line 122

def before(identifier, &block)
  Chef::Sugar::Filters::Injector.new(self, identifier, :before).evaluate(&block)
end

#best_ip_for(other) ⇒ Object

See Also:



45
# File 'lib/chef/sugar/ip.rb', line 45

def best_ip_for(other); Chef::Sugar::IP.best_ip_for(node, other); end

#cloud?Boolean

Returns:

  • (Boolean)

See Also:



134
# File 'lib/chef/sugar/cloud.rb', line 134

def cloud?; Chef::Sugar::Cloud.cloud?(node); end

#cloudstack?Boolean

Returns:

  • (Boolean)

See Also:



156
# File 'lib/chef/sugar/cloud.rb', line 156

def cloudstack?; Chef::Sugar::Cloud.cloudstack?(node); end

#compile_time(&block) ⇒ Object

Dynamically run resources specified in the block during the compilation phase, instead of the convergence phase.

Examples:

The old way

package('apache2') do
  action :nothing
end.run_action(:install)

The new way

compile_time do
  package('apache2')
end

Resource actions are run in order

compile_time do
  service 'apache2' do
    action [:enable, :start] # run_action(:enable), run_action(:start)
  end
end


102
103
104
# File 'lib/chef/sugar/filters.rb', line 102

def compile_time(&block)
  Chef::Sugar::Filters::CompileTime.new(self).evaluate(&block)
end

#dev_nullObject

See Also:



120
# File 'lib/chef/sugar/shell.rb', line 120

def dev_null; Chef::Sugar::Shell.dev_null(node); end

#ec2?Boolean

Returns:

  • (Boolean)

See Also:



137
# File 'lib/chef/sugar/cloud.rb', line 137

def ec2?; Chef::Sugar::Cloud.ec2?(node); end

#encrypted_data_bag_item(bag, id) ⇒ Object

See Also:

  • Chef::Sugar::DataBag#encrypted_data_bag_item?


74
75
76
# File 'lib/chef/sugar/data_bag.rb', line 74

def encrypted_data_bag_item(bag, id)
  Chef::Sugar::DataBag.encrypted_data_bag_item(bag, id)
end

#encrypted_data_bag_item_for_environment(bag, id) ⇒ Object

See Also:

  • Chef::Sugar::DataBag#encrypted_data_bag_item_for_environment?


79
80
81
# File 'lib/chef/sugar/data_bag.rb', line 79

def encrypted_data_bag_item_for_environment(bag, id)
  Chef::Sugar::DataBag.encrypted_data_bag_item_for_environment(node, bag, id)
end

#eucalyptus?Boolean Also known as: euca?

Returns:

  • (Boolean)

See Also:



146
# File 'lib/chef/sugar/cloud.rb', line 146

def eucalyptus?; Chef::Sugar::Cloud.eucalyptus?(node); end

#gce?Boolean

Returns:

  • (Boolean)

See Also:



140
# File 'lib/chef/sugar/cloud.rb', line 140

def gce?; Chef::Sugar::Cloud.gce?(node); end

#installed?(cmd) ⇒ Boolean

Returns:

  • (Boolean)

See Also:



123
# File 'lib/chef/sugar/shell.rb', line 123

def installed?(cmd); Chef::Sugar::Shell.installed?(cmd); end

#installed_at_version?(cmd, version, flag = '--version') ⇒ Boolean

Returns:

  • (Boolean)

See Also:



126
127
128
# File 'lib/chef/sugar/shell.rb', line 126

def installed_at_version?(cmd, version, flag = '--version')
  Chef::Sugar::Shell.installed_at_version?(cmd, version, flag)
end

#linode?Boolean

Returns:

  • (Boolean)

See Also:



150
# File 'lib/chef/sugar/cloud.rb', line 150

def linode?; Chef::Sugar::Cloud.linode?(node); end

#openstack?Boolean

Returns:

  • (Boolean)

See Also:



153
# File 'lib/chef/sugar/cloud.rb', line 153

def openstack?; Chef::Sugar::Cloud.openstack?(node); end

#rackspace?Boolean

Returns:

  • (Boolean)

See Also:



143
# File 'lib/chef/sugar/cloud.rb', line 143

def rackspace?; Chef::Sugar::Cloud.rackspace?(node); end

#ruby_19?Boolean

Returns:

  • (Boolean)

See Also:



48
# File 'lib/chef/sugar/ruby.rb', line 48

def ruby_19?; Chef::Sugar::Ruby.ruby_19?(node); end

#ruby_20?Boolean

Returns:

  • (Boolean)

See Also:



45
# File 'lib/chef/sugar/ruby.rb', line 45

def ruby_20?; Chef::Sugar::Ruby.ruby_20?(node); end

#vagrant?Boolean

Returns:

  • (Boolean)

See Also:



38
# File 'lib/chef/sugar/vagrant.rb', line 38

def vagrant?; Chef::Sugar::Vagrant.vagrant?(node); end

#version_for(cmd, flag = '--version') ⇒ Object

See Also:



131
132
133
# File 'lib/chef/sugar/shell.rb', line 131

def version_for(cmd, flag = '--version')
  Chef::Sugar::Shell.version_for(cmd, flag)
end

#which(cmd) ⇒ Object

See Also:



117
# File 'lib/chef/sugar/shell.rb', line 117

def which(cmd); Chef::Sugar::Shell.which(cmd); end