auster 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53c4b1f54eb6c85806e15fd5d0c10d084237143c
4
- data.tar.gz: 8fc7812b3c331168454559e81780a390214b1ff0
3
+ metadata.gz: 77f239157bba892dba58bba35d3f6c7f4e9fa962
4
+ data.tar.gz: 411670ff3bebba164215bfd07993dd9aa6982385
5
5
  SHA512:
6
- metadata.gz: 74bcbed24f715040cabe0063e56a77f8beeeedd8d3223a3480d2507ffa7f28e35014fb85681f64e169de51993802b91e9d8c92850a463363b98da38bab4ccc12
7
- data.tar.gz: 229f261906b6843db306c25a569f9dec2324038b2b0dbb638f04254f7e89199b8644d3b6af02c52d9493aba2692aec3be66b914cf09fbc9b43e6791798be5ff0
6
+ metadata.gz: 43b2d524317e0332e853b498448acc65651f1854c7a0113531820dc16e9df7bd56b01e428f227495d89d2ddd4c07f115b767b992d3d5e0f0c496c075b4ece481
7
+ data.tar.gz: e883ec1ddb96733f8722f7af91b3f68a8d95c3f4ce01e60fd7e31252010aa26a1a59960a560ad8e70d50577e6dd2798f7c45659b0f537992b86f27fbc2638ddd
data/README.md CHANGED
@@ -19,8 +19,8 @@ $ cd auster/example-repo
19
19
  Take a look around the repo if you'd like. Ensure that you have valid AWS credentials in your environment (`AWS_PROFILE`, etc.) and then run the following to create a pair of CloudFormation stacks. All they'll do is create S3 buckets, so you won't be charged for anything.
20
20
 
21
21
  ```bash
22
- $ auster run us-west-2/dev-ed1 bootstrap
23
- $ auster run us-west-2/dev-ed1 dependent
22
+ $ auster apply us-west-2/dev-ed1 bootstrap
23
+ $ auster apply us-west-2/dev-ed1 dependent
24
24
  ```
25
25
 
26
26
  If you read through the Auster output, you'll see that it's creating S3 buckets (as you'd expect--it's still CloudFormation under the hood) and registering them as region-wide exports, prefixed with the plan ID `dev1-ed`.
@@ -39,10 +39,10 @@ If you'd like more information on writing Cfer itself, check out [chef-cfer-cons
39
39
  - `auster generate step ##.human-tag` - Creates a new Auster step with stub files.
40
40
 
41
41
  ### Executors ###
42
- **Note:** In the command line interface, the step number and the tag are interchangeable. `auster run region/env 00` and `auster run region/env human-tag` will refer to the same step, `00.human-tag`.
42
+ **Note:** In the command line interface, the step number and the tag are interchangeable. `auster apply region/env 00` and `auster apply region/env human-tag` will refer to the same step, `00.human-tag`.
43
43
 
44
- - `auster json us-west-2/dev1-ed (##|human-tag)` - Uses `cfer generate` to generate the output JSON that will be applied when this step is `auster run`'d.
45
- - `auster run us-west-2/dev1-ed (##|human-tag)` - Runs step 01 in region `us-west2` with configuration set `dev1-ed`. This will:
44
+ - `auster json us-west-2/dev1-ed (##|human-tag)` - Uses `cfer generate` to generate the output JSON that will be applied when this step is `auster apply`'d.
45
+ - `auster apply us-west-2/dev1-ed (##|human-tag)` - Runs step 01 in region `us-west2` with configuration set `dev1-ed`. This will:
46
46
  - If `/cfg/_schema.yaml` exists, it will validate `/cfg/us-west2/dev1-ed.yaml` against it and fail if it does not validate.
47
47
  - If this is the first run of this step (there is no `dev1-ed-step01` CloudFormation stack in AWS), the scripts in `/steps/01/on-create.d` will be run in lexicographic order.
48
48
  - The scripts in `/steps/01/pre-converge.d` will be run in lexicographic order.
@@ -0,0 +1 @@
1
+ puts exports.inspect
File without changes
@@ -0,0 +1 @@
1
+ puts args.inspect
@@ -0,0 +1 @@
1
+ puts repo.root
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ require "cri"
3
+
4
+ require "cfer/auster/cli/_shared"
5
+
6
+ module Cfer
7
+ module Auster
8
+ module CLI
9
+ def self.apply
10
+ Cri::Command.define do
11
+ name "apply"
12
+ usage "apply aws-region/config-set count-or-tag"
13
+ description "Applies this Auster step against your AWS infrastructure."
14
+
15
+ CLI.standard_options(self)
16
+
17
+ run do |opts, args, cmd|
18
+ if args.length < 2
19
+ puts cmd.help
20
+ exit 1
21
+ else
22
+ CLI.repo_from_options(opts) do |repo|
23
+ args = args.dup
24
+ config_set = repo.config_set(args.shift)
25
+ step = repo.step_by_count_or_tag(args.shift)
26
+
27
+ step.apply(config_set)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -20,8 +20,9 @@ module Cfer
20
20
  exit 1
21
21
  else
22
22
  CLI.repo_from_options(opts) do |repo|
23
- config_set = repo.config_set(args[0])
24
- step = repo.step_by_count_or_tag(args[1])
23
+ args = args.dup
24
+ config_set = repo.config_set(args.shift)
25
+ step = repo.step_by_count_or_tag(args.shift)
25
26
 
26
27
  step.destroy(config_set)
27
28
  end
@@ -24,8 +24,9 @@ module Cfer
24
24
  exit 1
25
25
  else
26
26
  CLI.repo_from_options(opts) do |repo|
27
- config_set = repo.config_set(args[0])
28
- step = repo.step_by_count_or_tag(args[1])
27
+ args = args.dup
28
+ config_set = repo.config_set(args.shift)
29
+ step = repo.step_by_count_or_tag(args.shift)
29
30
 
30
31
  ret = step.json(config_set)
31
32
 
@@ -24,7 +24,8 @@ module Cfer
24
24
  exit 1
25
25
  else
26
26
  CLI.repo_from_options(opts) do |repo|
27
- config_set = repo.config_set(args[0])
27
+ args = args.dup
28
+ config_set = repo.config_set(args.shift)
28
29
 
29
30
  accepted = !!opts[:force]
30
31
 
@@ -6,11 +6,11 @@ require "cfer/auster/cli/_shared"
6
6
  module Cfer
7
7
  module Auster
8
8
  module CLI
9
- def self.run
9
+ def self.task
10
10
  Cri::Command.define do
11
- name "run"
12
- usage "run aws-region/config-set count-or-tag"
13
- description "Runs this Auster step against your AWS infrastructure."
11
+ name "task"
12
+ usage "task aws-region/config-set script-name [args]"
13
+ description "Runs a task within the context of an Auster config set."
14
14
 
15
15
  CLI.standard_options(self)
16
16
 
@@ -20,10 +20,11 @@ module Cfer
20
20
  exit 1
21
21
  else
22
22
  CLI.repo_from_options(opts) do |repo|
23
- config_set = repo.config_set(args[0])
24
- step = repo.step_by_count_or_tag(args[1])
23
+ args = args.dup
24
+ config_set = repo.config_set(args.shift)
25
+ task_name = args.shift
25
26
 
26
- step.run(config_set)
27
+ repo.run_task(task_name, config_set, args)
27
28
  end
28
29
  end
29
30
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require "cri"
3
+
4
+ require "cfer/auster/cli/_shared"
5
+
6
+ module Cfer
7
+ module Auster
8
+ module CLI
9
+ def self.tasks
10
+ Cri::Command.define do
11
+ name "tasks"
12
+ usage "tasks"
13
+ description "Prints a list of tasks available in this repo."
14
+
15
+ CLI.standard_options(self)
16
+
17
+ run do |opts, args, cmd|
18
+ CLI.repo_from_options(opts) do |repo|
19
+ repo.tasks.each { |t| puts t }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -7,8 +7,10 @@ require "cfer/auster"
7
7
  require "cfer/auster/cli/_shared"
8
8
  require "cfer/auster/cli/generate"
9
9
  require "cfer/auster/cli/json"
10
- require "cfer/auster/cli/run"
10
+ require "cfer/auster/cli/task"
11
+ require "cfer/auster/cli/tasks"
11
12
  require "cfer/auster/cli/destroy"
13
+ require "cfer/auster/cli/apply"
12
14
  require "cfer/auster/cli/nuke"
13
15
 
14
16
  module Cfer
@@ -45,7 +47,9 @@ module Cfer
45
47
 
46
48
  ret.add_command(CLI.generate)
47
49
  ret.add_command(CLI.json)
48
- ret.add_command(CLI.run)
50
+ ret.add_command(CLI.task)
51
+ ret.add_command(CLI.tasks)
52
+ ret.add_command(CLI.apply)
49
53
  ret.add_command(CLI.destroy)
50
54
  ret.add_command(CLI.nuke)
51
55
 
@@ -21,8 +21,6 @@ module Cfer
21
21
 
22
22
  @data[:PlanID] = @name
23
23
  @data[:AWSRegion] = @aws_region
24
-
25
- IceNine.deep_freeze(@data)
26
24
  end
27
25
 
28
26
  def full_name
@@ -73,6 +73,28 @@ module Cfer
73
73
  @steps.sort.map(&:last)
74
74
  end
75
75
 
76
+ def tasks
77
+ Dir["#{root}/tasks/**/*.rb"].reject { |f| File.basename(f).start_with?("_") }.map do |f|
78
+ f.gsub("#{root}/tasks/", "").gsub(/\.rb$/, "")
79
+ end
80
+ end
81
+
82
+ def run_task(task_name, config_set, args = [])
83
+ logger.debug "Attempting to run task '#{task_name}'."
84
+ task_file = "#{root}/tasks/#{task_name}.rb"
85
+
86
+ raise "task '#{task_name}' (#{task_file}) doesn't exist." \
87
+ unless File.file?(task_file)
88
+
89
+ Cfer::Auster::ScriptExecutor.new(
90
+ config_set.env_vars_for_shell.merge(
91
+ repo: self,
92
+ config_set: config_set,
93
+ args: args
94
+ )
95
+ ).run(task_file)
96
+ end
97
+
76
98
  def config_set(id)
77
99
  raise "Config set not found with id '#{id}'." unless @config_sets.include?(id)
78
100
 
@@ -62,7 +62,7 @@ module Cfer
62
62
  end
63
63
  end
64
64
 
65
- def run(config_set)
65
+ def apply(config_set)
66
66
  raise "config_set must be a Cfer::Auster::Config." unless config_set.is_a?(Cfer::Auster::Config)
67
67
 
68
68
  with_cfer(config_set) do |cfer|
@@ -1,5 +1,5 @@
1
1
  module Cfer
2
2
  module Auster
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Ropple
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -224,18 +224,24 @@ files:
224
224
  - example-repo/steps/01.dependent/on-destroy.d/00-debug.rb
225
225
  - example-repo/steps/01.dependent/post-converge.d/00-debug.rb
226
226
  - example-repo/steps/01.dependent/pre-converge.d/00-debug.rb
227
+ - example-repo/tasks/show-exports.rb
228
+ - example-repo/tasks/sub/_omitted.rb
229
+ - example-repo/tasks/sub/test-script.rb
230
+ - example-repo/tasks/test-script1.rb
227
231
  - lib/cfer/auster.rb
228
232
  - lib/cfer/auster/cfer_evaluator.rb
229
233
  - lib/cfer/auster/cfer_helpers.rb
230
234
  - lib/cfer/auster/cli.rb
231
235
  - lib/cfer/auster/cli/_shared.rb
236
+ - lib/cfer/auster/cli/apply.rb
232
237
  - lib/cfer/auster/cli/destroy.rb
233
238
  - lib/cfer/auster/cli/generate.rb
234
239
  - lib/cfer/auster/cli/generate/repo.rb
235
240
  - lib/cfer/auster/cli/generate/step.rb
236
241
  - lib/cfer/auster/cli/json.rb
237
242
  - lib/cfer/auster/cli/nuke.rb
238
- - lib/cfer/auster/cli/run.rb
243
+ - lib/cfer/auster/cli/task.rb
244
+ - lib/cfer/auster/cli/tasks.rb
239
245
  - lib/cfer/auster/config.rb
240
246
  - lib/cfer/auster/logging.rb
241
247
  - lib/cfer/auster/param_validator.rb