Module: Formatron::CLI::Generators::Bootstrap
- Defined in:
- lib/formatron/cli/generators/bootstrap.rb
Overview
CLI command for bootstrap generator rubocop:disable Metrics/ModuleLength
Instance Method Summary collapse
-
#bootstrap_action(c) ⇒ Object
rubocop:enable Metrics/MethodLength.
- #bootstrap_availability_zone(options) ⇒ Object
- #bootstrap_cookbooks_bucket_prefix(options) ⇒ Object
-
#bootstrap_directory(options) ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength.
- #bootstrap_ec2_key_pair(options) ⇒ Object
- #bootstrap_email(options) ⇒ Object
- #bootstrap_first_name(options) ⇒ Object
- #bootstrap_formatron_command ⇒ Object
- #bootstrap_hosted_zone_id(options) ⇒ Object
- #bootstrap_kms_key(options) ⇒ Object
- #bootstrap_last_name(options) ⇒ Object
- #bootstrap_name(options, directory) ⇒ Object
-
#bootstrap_options(c) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- #bootstrap_organization_full_name(options) ⇒ Object
- #bootstrap_organization_short_name(options) ⇒ Object
-
#bootstrap_params(options, directory) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #bootstrap_password(options) ⇒ Object
- #bootstrap_protected_targets(options) ⇒ Object
- #bootstrap_s3_bucket(options) ⇒ Object
- #bootstrap_targets(options) ⇒ Object
- #bootstrap_unprotected_targets(options) ⇒ Object
- #bootstrap_username(options) ⇒ Object
Instance Method Details
#bootstrap_action(c) ⇒ Object
rubocop:enable Metrics/MethodLength
227 228 229 230 231 232 233 234 235 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 227 def bootstrap_action(c) c.action do |_args, | directory = bootstrap_directory Formatron::Generators::Bootstrap.generate( directory, bootstrap_params(, directory) ) end end |
#bootstrap_availability_zone(options) ⇒ Object
132 133 134 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 132 def bootstrap_availability_zone() .availability_zone || ask('Availability Zone? ') end |
#bootstrap_cookbooks_bucket_prefix(options) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 136 def bootstrap_cookbooks_bucket_prefix() .cookbooks_bucket_prefix || ask( 'Chef Server Cookbooks Bucket Prefix? ' ) do |q| q.default = "#{.s3_bucket}-cookbooks" end end |
#bootstrap_directory(options) ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
104 105 106 107 108 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 104 def bootstrap_directory() .directory || ask('Directory? ') do |q| q.default = Dir.pwd end end |
#bootstrap_ec2_key_pair(options) ⇒ Object
124 125 126 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 124 def bootstrap_ec2_key_pair() .ec2_key_pair || ask('EC2 Key Pair? ') end |
#bootstrap_email(options) ⇒ Object
162 163 164 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 162 def bootstrap_email() .email || ask('Chef Server User Email? ') end |
#bootstrap_first_name(options) ⇒ Object
166 167 168 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 166 def bootstrap_first_name() .first_name || ask('Chef Server User First Name? ') end |
#bootstrap_formatron_command ⇒ Object
237 238 239 240 241 242 243 244 245 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 237 def bootstrap_formatron_command command :'generate bootstrap' do |c| c.syntax = 'formatron generate bootstrap [options]' c.summary = 'Generate a bootstrap configuration' c.description = 'Generate a bootstrap configuration' c bootstrap_action c end end |
#bootstrap_hosted_zone_id(options) ⇒ Object
128 129 130 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 128 def bootstrap_hosted_zone_id() .hosted_zone_id || ask('Hosted Zone ID? ') end |
#bootstrap_kms_key(options) ⇒ Object
120 121 122 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 120 def bootstrap_kms_key() .kms_key || ask('KMS Key? ') end |
#bootstrap_last_name(options) ⇒ Object
170 171 172 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 170 def bootstrap_last_name() .last_name || ask('Chef Server User Last Name? ') end |
#bootstrap_name(options, directory) ⇒ Object
110 111 112 113 114 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 110 def bootstrap_name(, directory) .name || ask('Name? ') do |q| q.default = File.basename directory end end |
#bootstrap_options(c) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
11 12 13 14 15 16 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 11 def (c) c.option '-n', '--name STRING', 'The name for the configuration' c.option( '-s', '--s3-bucket STRING', 'The S3 bucket to store encrypted configuration' ) c.option( '-k', '--kms-key STRING', 'The KMS key to use for encryption' ) c.option( '-e', '--ec2-key-pair STRING', 'The EC2 key pair to associate with EC2 instances' ) c.option( '-z', '--hosted-zone-id STRING', 'The Route53 Hosted Zone ID for the public hosted zone' ) c.option( '-a', '--availability-zone STRING', 'The AWS availability zone letter (region is already taken ' \ 'from the AWS credentials)' ) c.option( '-b', '--cookbooks-bucket-prefix STRING', 'Used to generate target specific S3 bucket names ' \ '(PREFIX-TARGET) for the Chef Server to store its ' \ 'cookbook library' ) c.option( '-o', '--organization-short-name STRING', 'The short name of the organization to create on the ' \ 'Chef Server (should not contain spaces, etc)' ) c.option( '-w', '--organization-full-name STRING', 'The full name of the organization to create on the Chef Server' ) c.option( '-u', '--username STRING', 'The username to create on the Chef Server' ) c.option( '-p', '--password STRING', 'The password for the Chef Server user' ) c.option( '-m', '--email STRING', 'The email address for the Chef Server user' ) c.option( '-f', '--first-name STRING', 'The first name of the Chef Server user' ) c.option( '-l', '--last-name STRING', 'The last name of the Chef Server user' ) c.option( '-i', '--instance-cookbook STRING', 'The instance cookbook to apply additional ' \ 'configuration to the Chef Server' ) c.option( '-x', '--protected-targets LIST', Array, 'The protected targets (eg. production)' ) c.option( '-q', '--unprotected-targets LIST', Array, 'The unprotected targets (eg. test)' ) end |
#bootstrap_organization_full_name(options) ⇒ Object
149 150 151 152 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 149 def bootstrap_organization_full_name() .organization_full_name || ask('Chef Server Organization Full Name? ') end |
#bootstrap_organization_short_name(options) ⇒ Object
144 145 146 147 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 144 def bootstrap_organization_short_name() .organization_short_name || ask('Chef Server Organization Short Name? ') end |
#bootstrap_params(options, directory) ⇒ Object
rubocop:disable Metrics/MethodLength
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 201 def bootstrap_params(, directory) { name: bootstrap_name(, directory), s3_bucket: bootstrap_s3_bucket(), kms_key: bootstrap_kms_key(), ec2_key_pair: bootstrap_ec2_key_pair(), hosted_zone_id: bootstrap_hosted_zone_id(), availability_zone: bootstrap_availability_zone(), chef_server: { cookbooks_bucket_prefix: bootstrap_cookbooks_bucket_prefix(), organization: { short_name: bootstrap_organization_short_name(), full_name: bootstrap_organization_full_name() }, username: bootstrap_username(), password: bootstrap_password(), email: bootstrap_email(), first_name: bootstrap_first_name(), last_name: bootstrap_last_name() }, targets: bootstrap_targets() } end |
#bootstrap_password(options) ⇒ Object
158 159 160 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 158 def bootstrap_password() .password || password('Chef Server Password? ') end |
#bootstrap_protected_targets(options) ⇒ Object
174 175 176 177 178 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 174 def bootstrap_protected_targets() .protected_targets || ask('Protected Targets? ', Array) do |q| q.default = 'production' end end |
#bootstrap_s3_bucket(options) ⇒ Object
116 117 118 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 116 def bootstrap_s3_bucket() .s3_bucket || ask('S3 Bucket? ') end |
#bootstrap_targets(options) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 187 def bootstrap_targets() protected_targets = bootstrap_protected_targets unprotected_targets = bootstrap_unprotected_targets targets = {} protected_targets.each do |target| targets[target.to_sym] = { protect: true } end unprotected_targets.each do |target| targets[target.to_sym] = { protect: false } end targets end |
#bootstrap_unprotected_targets(options) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 180 def bootstrap_unprotected_targets() .unprotected_targets || ask('Unprotected Targets? ', Array) do |q| q.default = 'test' end end |
#bootstrap_username(options) ⇒ Object
154 155 156 |
# File 'lib/formatron/cli/generators/bootstrap.rb', line 154 def bootstrap_username() .username || ask('Chef Server Username? ') end |