Module: R10K::Settings

Defined in:
lib/r10k/settings.rb,
lib/r10k/settings/list.rb,
lib/r10k/settings/loader.rb,
lib/r10k/settings/helpers.rb,
lib/r10k/settings/collection.rb,
lib/r10k/settings/definition.rb,
lib/r10k/settings/uri_definition.rb,
lib/r10k/settings/enum_definition.rb

Defined Under Namespace

Modules: Helpers, Mixin Classes: Collection, Container, Definition, EnumDefinition, List, Loader, URIDefinition

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.puppet_pathObject

Path to puppet executable



14
15
16
# File 'lib/r10k/settings.rb', line 14

def puppet_path
  @puppet_path
end

Class Method Details

.deploy_settingsObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/r10k/settings.rb', line 85

def self.deploy_settings
  R10K::Settings::Collection.new(:deploy, [
    Definition.new(:write_lock, {
      :desc => "Whether r10k deploy actions should be locked out in case r10k is being managed
      by another application. The value should be a string containing the reason for the write lock.",
      :validate => lambda do |value|
        if value && !value.is_a?(String)
          raise ArgumentError, "The write_lock setting should be a string containing the reason for the write lock, not a #{value.class}"
        end
      end
    }),

    EnumDefinition.new(:purge_levels, {
      :desc => "Controls how aggressively r10k will purge unmanaged content from the target directory. Should be a list of values indicating at what levels unmanaged content should be purged. Options are 'deployment', 'environment', and 'puppetfile'. For backwards compatibility, the default is ['deployment', 'puppetfile'].",
      :multi => true,
      :enum => [:deployment, :environment, :puppetfile],
      :default => [:deployment, :puppetfile],
      :normalize => lambda do |input|
        if input.respond_to?(:collect)
          input.collect { |val| val.to_sym }
        else
          # Convert single values to a list of one symbolized value.
          [input.to_sym]
        end
      end,
    }),

    Definition.new(:purge_whitelist, {
      :desc => "A list of filename patterns to be excluded from any purge operations. Patterns are matched relative to the root of each deployed environment, if you want a pattern to match recursively you need to use the '**' glob in your pattern. Basic shell style globs are supported.",
      :default => [],
    }),

    Definition.new(:generate_types, {
      :desc => "Controls whether to generate puppet types after deploying an environment. Defaults to false.",
      :default => false,
      :normalize => lambda do |input|
        input.to_s == 'true'
      end,
    }),

    Definition.new(:puppet_path, {
      :desc => "Path to puppet executable. Defaults to /opt/puppetlabs/bin/puppet.",
      :default => '/opt/puppetlabs/bin/puppet',
      :validate => lambda do |value|
        unless File.executable? value
          raise ArgumentError, "The specified puppet executable #{value} is not executable"
        end
      end
    }),
  ])
end

.forge_settingsObject



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/r10k/settings.rb', line 72

def self.forge_settings
  R10K::Settings::Collection.new(:forge, [
    URIDefinition.new(:proxy, {
      :desc => "An optional proxy server to use when downloading modules from the forge.",
      :default => :inherit,
    }),

    URIDefinition.new(:baseurl, {
      :desc => "The URL to the Puppet Forge to use for downloading modules."
    }),
  ])
end

.git_settingsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/r10k/settings.rb', line 17

def self.git_settings
  R10K::Settings::Collection.new(:git, [

    EnumDefinition.new(:provider, {
      :desc => "The Git provider to use. Valid values: 'shellgit', 'rugged'",
      :normalize => lambda { |input| input.to_sym },
      :enum => [:shellgit, :rugged],
    }),

    Definition.new(:username, {
      :desc => "The username to use for Git SSH remotes that do not specify a user.
                Only used by the 'rugged' Git provider.
                Default: the current user",
      :default => lambda { Etc.getlogin },
    }),

    Definition.new(:private_key, {
      :desc => "The path to the SSH private key for Git SSH remotes.
                Only used by the 'rugged' Git provider.",
    }),

    URIDefinition.new(:proxy, {
      :desc => "An optional proxy server to use when interacting with Git sources via HTTP(S).",
      :default => :inherit,
    }),

    List.new(:repositories, lambda {
      R10K::Settings::Collection.new(nil, [
        Definition.new(:remote, {
          :desc => "Remote source that repository-specific settings should apply to.",
        }),

        Definition.new(:private_key, {
          :desc => "The path to the SSH private key for Git SSH remotes.
                    Only used by the 'rugged' Git provider.",
          :default => :inherit,
        }),

        URIDefinition.new(:proxy, {
          :desc => "An optional proxy server to use when interacting with Git sources via HTTP(S).",
          :default => :inherit,
        }),
        
        Definition.new(:ignore_branch_prefixes, {
          :desc => "Array of strings used to prefix branch names that will not be deployed as environments.",
        }),
      ])
    },
    {
      :desc => "Repository specific configuration.",
      :default => [],
    }),
  ])
end

.global_settingsObject



137
138
139
140
141
142
143
144
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
185
186
187
188
189
190
191
192
# File 'lib/r10k/settings.rb', line 137

def self.global_settings
  R10K::Settings::Collection.new(:global, [
    Definition.new(:sources, {
      :desc => "Where r10k should retrieve sources when deploying environments.
                Only used for r10k environment deployment.",
    }),

    Definition.new(:purgedirs, {
      :desc => "The purgedirs setting was deprecated in r10k 1.0.0 and is no longer respected.",
    }),

    Definition.new(:cachedir, {
      :desc => "Where r10k should store cached Git repositories.",
    }),

    Definition.new(:postrun, {
      :desc => "The command r10k should run after deploying environments.",
      :validate => lambda do |value|
        if !value.is_a?(Array)
          raise ArgumentError, "The postrun setting should be an array of strings, not a #{value.class}"
        end
      end
    }),

    Definition.new(:pool_size, {
      :desc => "The amount of threads used to concurrently install modules. The default value is 1: install one module at a time.",
      :default => 1,
      :validate => lambda do |value|
        if !value.is_a?(Integer)
          raise ArgumentError, "The pool_size setting should be an integer, not a #{value.class}"
        end
        if !(value > 0)
          raise ArgumentError, "The pool_size setting should be greater than zero."
        end
      end
    }),

    URIDefinition.new(:proxy, {
      :desc => "Proxy to use for all r10k operations which occur over HTTP(S).",
      :default => lambda {
        [
          ENV['HTTPS_PROXY'],
          ENV['https_proxy'],
          ENV['HTTP_PROXY'],
          ENV['http_proxy']
        ].find { |value| value }
      },
    }),

    R10K::Settings.forge_settings,

    R10K::Settings.git_settings,

    R10K::Settings.deploy_settings,
  ])
end