Module: OwncloudCookbook::CookbookHelpers
- Included in:
- FakeRecipe
- Defined in:
- libraries/cookbook_helpers.rb
Overview
Some helpers to use from owncloud
cookbook recipes or resources.
Instance Method Summary collapse
-
#apply_owncloud_configuration ⇒ Object
Calculates new configuration options, merged them and save them on disk.
-
#calculate_dbhost ⇒ String
Calculates the database host.
-
#calculate_trusted_domains ⇒ Array
Adds server name and server aliases to trusted_domains configuration option.
-
#owncloud_config ⇒ OwncloudCookbook::Config
Returns the [OwncloudCookbook::Config] instance.
-
#owncloud_config_file ⇒ String
Gets the ownCloud configuration file full path.
-
#owncloud_config_update ⇒ Object
Updates the disk configuration values from the new calculated values.
-
#owncloud_cookbook_config ⇒ Hash
Gets ownCloud default configuration values.
-
#owncloud_trusted_domains ⇒ Array
Generates the ownCloud trusted domain list.
-
#save_owncloud_node_configuration ⇒ Object
Store important options that where generated automatically by the setup.
Instance Method Details
#apply_owncloud_configuration ⇒ Object
Calculates new configuration options, merged them and save them on disk.
- Calculates trusted domains.
- Calculates database host.
- Updates ownCloud configuration options on disk.
- Saves some generated options in Chef Node attributes.
150 151 152 153 154 155 |
# File 'libraries/cookbook_helpers.rb', line 150 def apply_owncloud_configuration calculate_trusted_domains calculate_dbhost owncloud_config_update save_owncloud_node_configuration end |
#calculate_dbhost ⇒ String
Calculates the database host.
103 104 105 106 107 108 |
# File 'libraries/cookbook_helpers.rb', line 103 def calculate_dbhost owncloud_cookbook_config['dbhost'] = [ owncloud_cookbook_config['dbhost'], owncloud_cookbook_config['dbport'] ].join(':') end |
#calculate_trusted_domains ⇒ Array
Adds server name and server aliases to trusted_domains configuration option.
Merges the generated owncloud trusted domains and the
node['owncloud']['config']['trusted_domains']
attribute values.
87 88 89 90 91 92 93 94 95 |
# File 'libraries/cookbook_helpers.rb', line 87 def calculate_trusted_domains unless owncloud_cookbook_config.key?('trusted_domains') owncloud_cookbook_config['trusted_domains'] = [] end owncloud_trusted_domains.each do |domain| next if owncloud_cookbook_config['trusted_domains'].include?(domain) owncloud_cookbook_config['trusted_domains'] << domain end end |
#owncloud_config ⇒ OwncloudCookbook::Config
Returns the [OwncloudCookbook::Config] instance.
46 47 48 |
# File 'libraries/cookbook_helpers.rb', line 46 def owncloud_config @owncloud_config ||= OwncloudCookbook::Config.new(owncloud_config_file) end |
#owncloud_config_file ⇒ String
Gets the ownCloud configuration file full path.
36 37 38 |
# File 'libraries/cookbook_helpers.rb', line 36 def owncloud_config_file ::File.join(node['owncloud']['dir'], 'config', 'config.php') end |
#owncloud_config_update ⇒ Object
Updates the disk configuration values from the new calculated values.
Merges all the configuration values.
118 119 120 121 122 |
# File 'libraries/cookbook_helpers.rb', line 118 def owncloud_config_update owncloud_config.merge(owncloud_cookbook_config) owncloud_config.write owncloud_config end |
#owncloud_cookbook_config ⇒ Hash
Gets ownCloud default configuration values.
57 58 59 |
# File 'libraries/cookbook_helpers.rb', line 57 def owncloud_cookbook_config @owncloud_cookbook_config ||= node['owncloud']['config'].to_hash end |
#owncloud_trusted_domains ⇒ Array
Generates the ownCloud trusted domain list.
Generates the domain list from the node['owncloud']['server_name']
and
the node['owncloud']['server_aliases']
attribute values.
70 71 72 73 74 |
# File 'libraries/cookbook_helpers.rb', line 70 def owncloud_trusted_domains [ node['owncloud']['server_name'], node['owncloud']['server_aliases'] ].flatten end |
#save_owncloud_node_configuration ⇒ Object
Store important options that where generated automatically by the setup.
Saves them in Chef Node attributes.
132 133 134 135 136 137 |
# File 'libraries/cookbook_helpers.rb', line 132 def save_owncloud_node_configuration return if Chef::Config[:solo] %w(passwordsalt instanceid).each do |value| node.set_unless['owncloud']['config'][value] = owncloud_config[value] end end |