ansible-ruby 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 727699f832b62d2e6870209e65cbef3d3324b27c
4
- data.tar.gz: 9f1012dd3e2979a07227e337cf7b055a20d246b3
3
+ metadata.gz: ac48e9bfedb879d6fb1753c6c2b79df842d98c4a
4
+ data.tar.gz: 394d70113ee27243bd101164f9569c1f22b308a8
5
5
  SHA512:
6
- metadata.gz: c44972041ab6bb679378e79288ce3e973b5c0f5c50729e1ca5629178e9521ced8f5934f47689640f438f595307a716dcd54df197f32f7bff830b9f4f0d539b4d
7
- data.tar.gz: 25d9c8ef06bd5065d23664bf9c8d403677316d5644247fd4c804d7e3ba1f7d480dd55c2c4436ae19f01921893f8ffe21718352b5255ffb8a01a628c82d87c78c
6
+ metadata.gz: 196c4553ec3b99551e11afd1b283018ebeb95c08a2417665b91182a8a76b75214c574f1e05a2662d99f9c7c596d5d8ec8f49449ef2ae4ba05be5ee96e37cef07
7
+ data.tar.gz: 5bfee2cc930f3326b80f360706c728e06aa03285e8bb79ef9eff4c6e411f9084754ada1efb08338052deca84d45da3d5c99bdb94d1557249a777b4a9845aaf4c
@@ -38,7 +38,7 @@ module Ansible
38
38
  end
39
39
 
40
40
  def _valid_attributes
41
- (self.class.instance_methods - Object.instance_methods - [:_result, :method_missing])
41
+ (self.class.instance_methods - Object.instance_methods - [:_result, :method_missing, :validate?])
42
42
  end
43
43
 
44
44
  def no_method_error(method, only_valid_clause)
@@ -10,6 +10,7 @@ module Ansible
10
10
  @plays = []
11
11
  @tasks_builder = nil
12
12
  @context = nil
13
+ @includes = []
13
14
  end
14
15
 
15
16
  def play(name = nil, &block)
@@ -34,6 +35,10 @@ module Ansible
34
35
  @tasks_builder.handler name, &block
35
36
  end
36
37
 
38
+ def ansible_include(filename, &block)
39
+ @includes << _ansible_include(filename, &block)
40
+ end
41
+
37
42
  def _handled_eval(ruby_filename)
38
43
  ruby_code = File.read ruby_filename
39
44
  instance_eval ruby_code, ruby_filename
@@ -57,9 +62,12 @@ module Ansible
57
62
  case @context
58
63
  when :playbook
59
64
  # TODO: Add a playbook DSL and do this like tasks
60
- Models::Playbook.new plays: @plays
65
+ Models::Playbook.new plays: @plays,
66
+ inclusions: @includes
61
67
  when :tasks, :handlers
62
- @tasks_builder._result
68
+ tasks_model = @tasks_builder._result
69
+ tasks_model.inclusions += @includes
70
+ tasks_model
63
71
  when nil
64
72
  raise 'Must supply at least 1 handler/task/play!'
65
73
  else
@@ -74,9 +82,7 @@ module Ansible
74
82
  private
75
83
 
76
84
  def _validate_context(expected)
77
- if @context && @context != expected
78
- raise "This is a #{@context} file, cannot use #{expected} here!"
79
- end
85
+ raise "This is a #{@context} file, cannot use #{expected} here!" if @context && @context != expected
80
86
  end
81
87
  end
82
88
  end
@@ -1,7 +1,7 @@
1
1
  require 'ansible/ruby/dsl_builders/base'
2
2
  require 'ansible/ruby/dsl_builders/args'
3
3
  require 'ansible/ruby/modules/base'
4
- require 'ansible/ruby/modules/custom/free_form'
4
+ require 'ansible/ruby/modules/free_form'
5
5
  require 'ansible/ruby/dsl_builders/jinja_item_node'
6
6
 
7
7
  module Ansible
@@ -64,12 +64,9 @@ module Ansible
64
64
  end
65
65
 
66
66
  def _free_form_arg(module_args)
67
- if module_args.any?
68
- raise 'Expected only 1 argument for this type of module' if module_args.length > 1
69
- module_args[0]
70
- else
71
- raise 'Expected 1 argument for this type of module'
72
- end
67
+ raise 'Expected 1 argument for this type of module' unless module_args.any?
68
+ raise 'Expected only 1 argument for this type of module' if module_args.length > 1
69
+ module_args[0]
73
70
  end
74
71
  end
75
72
  end
@@ -16,6 +16,10 @@ module Ansible
16
16
  @play_args[:hosts] = value
17
17
  end
18
18
 
19
+ def no_log(value)
20
+ @play_args[:no_log] = value
21
+ end
22
+
19
23
  def roles(value)
20
24
  @play_args[:roles] = value
21
25
  end
@@ -58,12 +62,15 @@ module Ansible
58
62
  def block(&block)
59
63
  builder = Block.new
60
64
  builder.instance_eval(&block)
61
- @items << builder._result
65
+ @tasks << builder._result
62
66
  end
63
67
 
64
68
  # allow any order
65
69
  def _result
66
70
  tasks = super
71
+ if tasks.inclusions.any? && @play_args[:roles]
72
+ raise 'Includes cannot be used in a play using a role. They can only be used in task files or in plays with a task list.'
73
+ end
67
74
  args = @play_args.merge({})
68
75
  # Don't want to trigger validation
69
76
  args[:tasks] = tasks if tasks.items.any?
@@ -17,6 +17,10 @@ module Ansible
17
17
  @temp_counter = temp_counter
18
18
  end
19
19
 
20
+ def no_log(value)
21
+ @task_args[:no_log] = value
22
+ end
23
+
20
24
  def changed_when(clause)
21
25
  @task_args[:changed_when] = clause
22
26
  end
@@ -62,31 +66,32 @@ module Ansible
62
66
  }.merge @task_args
63
67
  args[:inclusion] = @inclusion if @inclusion
64
68
  task = @context.new args
65
- task.validate!
69
+ # Quick feedback if the type is wrong, etc.
70
+ task.validate! if validate?
66
71
  task
67
72
  end
68
73
 
74
+ def validate?
75
+ true
76
+ end
77
+
69
78
  private
70
79
 
71
80
  def _process_method(id, *args, &block)
72
81
  _check_context if id == :ansible_include
73
82
  mcb = ModuleCall.new
83
+ # only 1 module allowed per task, give a good error message
74
84
  if @module && mcb.respond_to?(id)
75
- # only 1 module allowed per task, give a good error message
76
85
  raise "Invalid module call `#{id}' since `#{@module.ansible_name}' module has already been used in this task. Only valid options are #{_valid_attributes}"
77
- elsif @module
78
- no_method_error id, "Only valid options are #{_valid_attributes}"
79
86
  end
87
+ no_method_error id, "Only valid options are #{_valid_attributes}" if @module
80
88
  mcb.send(id, *args, &block)
81
89
  @module = mcb._result
82
90
  end
83
91
 
84
92
  def _check_context
85
- if @context == Models::Handler
86
- raise "Can't call inclusion inside a handler(yet), only in plays/handlers"
87
- else
88
- raise "Can't call inclusion inside a task, only in plays/handlers"
89
- end
93
+ raise "Can't call inclusion inside a handler(yet), only in plays/handlers" if @context == Models::Handler
94
+ raise "Can't call inclusion inside a task, only in plays/handlers"
90
95
  end
91
96
 
92
97
  def method_missing_return(_id, _result, *_args)
@@ -9,17 +9,19 @@ module Ansible
9
9
  class Tasks < Base
10
10
  def initialize(context)
11
11
  @context = context
12
- @items = []
12
+ @tasks = []
13
+ @includes = []
13
14
  @temp_counter = 0
14
15
  end
15
16
 
16
17
  def ansible_include(filename, &block)
17
- @items << _ansible_include(filename, &block)
18
+ @includes << _ansible_include(filename, &block)
18
19
  end
19
20
 
20
21
  # allow multiple tasks, etc.
21
22
  def _result
22
- Models::Tasks.new items: @items
23
+ Models::Tasks.new items: @tasks,
24
+ inclusions: @includes
23
25
  end
24
26
 
25
27
  class << self
@@ -70,7 +72,7 @@ module Ansible
70
72
  @temp_counter += 1
71
73
  task_builder = Task.new name, model, @temp_counter
72
74
  task_builder.instance_eval(&block)
73
- @items << task_builder._result
75
+ @tasks << task_builder._result
74
76
  end
75
77
  end
76
78
  end
@@ -45,12 +45,10 @@ module Ansible
45
45
  # avoid having to dupe this in the :attribute call
46
46
  hash = attributes.length > 1 && attributes[1]
47
47
  type_validator = hash && hash[:type]
48
- return unless type_validator
49
- if type_validator.is_a?(TypeGeneric)
50
- name = attributes[0]
51
- for_name = attr_options[name] ||= {}
52
- for_name[:generic] = type_validator.klasses
53
- end
48
+ return unless type_validator && type_validator.is_a?(TypeGeneric)
49
+ name = attributes[0]
50
+ for_name = attr_options[name] ||= {}
51
+ for_name[:generic] = type_validator.klasses
54
52
  end
55
53
  end
56
54
 
@@ -13,6 +13,8 @@ module Ansible
13
13
  validates :become_user, type: String
14
14
  attribute :ignore_errors
15
15
  validates :ignore_errors, type: MultipleTypes.new(TrueClass, FalseClass)
16
+ attribute :no_log
17
+ validates :no_log, type: MultipleTypes.new(TrueClass, FalseClass)
16
18
  attribute :name
17
19
  validates :name, type: String
18
20
  attribute :tasks
@@ -6,10 +6,13 @@ module Ansible
6
6
  class Playbook < Base
7
7
  attribute :plays
8
8
  validates :plays, presence: true, type: TypeGeneric.new(Play)
9
+ attribute :inclusions
10
+ validates :inclusions, type: TypeGeneric.new(Inclusion)
9
11
 
10
12
  def to_h
13
+ super_result = super
11
14
  # Don't need to return highest level
12
- super[:plays]
15
+ super_result[:plays] + (super_result[:inclusions] || [])
13
16
  end
14
17
  end
15
18
  end
@@ -14,6 +14,8 @@ module Ansible
14
14
  validates :failed_when, type: String
15
15
  attribute :with_dict
16
16
  validates :with_dict, type: MultipleTypes.new(String, Hash)
17
+ attribute :no_log
18
+ validates :no_log, type: MultipleTypes.new(TrueClass, FalseClass)
17
19
  attribute :with_items
18
20
  validates :with_items, type: MultipleTypes.new(String, Array)
19
21
  validate :loop_and_dict
@@ -9,10 +9,13 @@ module Ansible
9
9
  class Tasks < Base
10
10
  attribute :items
11
11
  validates :items, presence: true, type: TypeGeneric.new(Task, Block, Inclusion)
12
+ attribute :inclusions
13
+ validates :inclusions, type: TypeGeneric.new(Inclusion)
12
14
 
13
15
  def to_h
16
+ super_result = super
14
17
  # Don't need to return highest level
15
- super[:items]
18
+ (super_result[:inclusions] || []) + super_result[:items]
16
19
  end
17
20
  end
18
21
  end
@@ -573,3 +573,4 @@ ansible_mod.autoload(:Win_unzip, 'ansible/ruby/modules/generated/extras/windows/
573
573
  ansible_mod.autoload(:Win_updates, 'ansible/ruby/modules/generated/extras/windows/win_updates')
574
574
  ansible_mod.autoload(:Win_uri, 'ansible/ruby/modules/generated/extras/windows/win_uri')
575
575
  ansible_mod.autoload(:Win_webpicmd, 'ansible/ruby/modules/generated/extras/windows/win_webpicmd')
576
+ ansible_mod.autoload(:Include_vars, 'ansible/ruby/modules/custom/utilities/include_vars')
@@ -2,7 +2,7 @@
2
2
 
3
3
  # VALIDATED_CHECKSUM: JQvTPI3GbhVRRPRvDgbzLeeuYLABoDT7ogPPA2odrHs=
4
4
 
5
- require 'ansible/ruby/modules/custom/free_form'
5
+ require 'ansible/ruby/modules/free_form'
6
6
  require 'ansible/ruby/modules/generated/core/commands/command'
7
7
 
8
8
  module Ansible
@@ -1,7 +1,7 @@
1
1
  # VALIDATED_CHECKSUM: aHiGPJ0CGZvoBX3EPdvSwymkBZ1qlHyXEBrLfi27C6A=
2
2
  # See LICENSE.txt for license
3
3
 
4
- require 'ansible/ruby/modules/custom/free_form'
4
+ require 'ansible/ruby/modules/free_form'
5
5
  require 'ansible/ruby/modules/generated/core/commands/raw'
6
6
 
7
7
  module Ansible
@@ -1,7 +1,7 @@
1
1
  # VALIDATED_CHECKSUM: RhHDiVtIFNT3I5ESwjmmuJBl8pv6qi2oIyGxPsjxmpE=
2
2
  # See LICENSE.txt for license
3
3
 
4
- require 'ansible/ruby/modules/custom/free_form'
4
+ require 'ansible/ruby/modules/free_form'
5
5
  require 'ansible/ruby/modules/generated/core/commands/script'
6
6
 
7
7
  module Ansible
@@ -1,7 +1,7 @@
1
1
  # VALIDATED_CHECKSUM: hbLqxsuZqxyO5SXR1JlPnhnNc6lrDZBDWwhN+7UNW7Q=
2
2
  # See LICENSE.txt for license
3
3
 
4
- require 'ansible/ruby/modules/custom/free_form'
4
+ require 'ansible/ruby/modules/free_form'
5
5
  require 'ansible/ruby/modules/generated/core/commands/shell'
6
6
 
7
7
  module Ansible
@@ -0,0 +1,14 @@
1
+ require 'ansible/ruby/modules/free_form'
2
+
3
+ module Ansible
4
+ module Ruby
5
+ module Modules
6
+ class Include_vars < Base
7
+ attribute :free_form
8
+ validates :free_form, presence: true
9
+
10
+ include FreeForm
11
+ end
12
+ end
13
+ end
14
+ end
@@ -14,7 +14,7 @@ module Ansible
14
14
  attribute :dockerfile
15
15
  validates :dockerfile, type: String
16
16
 
17
- # @return [Boolean, nil] Use with absent state to un-tag and remove all images matching the specified name. Use with states 'present' and 'tagged' to take action even when an image already exists.
17
+ # @return [Boolean, nil] Use with state I(absent) to un-tag and remove all images matching the specified name. Use with state C(present) to build, load or pull an image when the image already exists.
18
18
  attribute :force
19
19
  validates :force, inclusion: {:in=>[true, false], :message=>"%{value} needs to be true, false"}, allow_nil: true
20
20
 
@@ -45,9 +45,9 @@ module Ansible
45
45
  attribute :repository
46
46
  validates :repository, type: String
47
47
 
48
- # @return [:absent, :present, :"build (DEPRECATED)", nil] Make assertions about the state of an image.,When 'absent' an image will be removed. Use the force option to un-tag and remove all images matching the provided name.,When 'present' check if an image exists using the provided name and tag. If the image is not found or the force option is used, the image will either be pulled, built or loaded. By default the image will be pulled from Docker Hub. To build the image, provide a path value set to a directory containing a context and Dockerfile. To load an image, specify load_path to provide a path to an archive file. To tag an image to a repository, provide a repository path. If the name contains a repository path, it will be pushed.,NOTE: 'build' is DEPRECATED. Specifying 'build' will behave the same as 'present'.
48
+ # @return [:absent, :present, :build, nil] Make assertions about the state of an image.,When 'absent' an image will be removed. Use the force option to un-tag and remove all images matching the provided name.,When 'present' check if an image exists using the provided name and tag. If the image is not found or the force option is used, the image will either be pulled, built or loaded. By default the image will be pulled from Docker Hub. To build the image, provide a path value set to a directory containing a context and Dockerfile. To load an image, specify load_path to provide a path to an archive file. To tag an image to a repository, provide a repository path. If the name contains a repository path, it will be pushed.,NOTE: C(build) is DEPRECATED and will be removed in release 2.3. Specifying C(build) will behave the same as C(present).
49
49
  attribute :state
50
- validates :state, inclusion: {:in=>[:absent, :present, :"build (DEPRECATED)"], :message=>"%{value} needs to be :absent, :present, :\"build (DEPRECATED)\""}, allow_nil: true
50
+ validates :state, inclusion: {:in=>[:absent, :present, :build], :message=>"%{value} needs to be :absent, :present, :build"}, allow_nil: true
51
51
 
52
52
  # @return [String, nil] Used to select an image when pulling. Will be added to the image when pushing, tagging or building. Defaults to 'latest' when pulling an image.
53
53
  attribute :tag
@@ -14,9 +14,9 @@ module Ansible
14
14
  attribute :dest
15
15
  validates :dest, presence: true
16
16
 
17
- # @return [Integer, nil] Port number for ssh on the destination host. Prior to ansible 2.0, the ansible_ssh_port inventory var took precedence over this value.
17
+ # @return [Array<String>, String, nil] Port number for ssh on the destination host. Prior to ansible 2.0, the ansible_ssh_port inventory var took precedence over this value.
18
18
  attribute :dest_port
19
- validates :dest_port, type: Integer
19
+ validates :dest_port, type: TypeGeneric.new(String)
20
20
 
21
21
  # @return [:push, :pull, nil] Specify the direction of the synchronization. In push mode the localhost or delegate is the source; In pull mode the remote host in context is the source.
22
22
  attribute :mode
@@ -6,11 +6,11 @@ module Ansible
6
6
  module Ruby
7
7
  module Modules
8
8
  class Nxos_feature < Base
9
- # @return [String] Name of feature
9
+ # @return [String] Name of feature.
10
10
  attribute :feature
11
11
  validates :feature, presence: true, type: String
12
12
 
13
- # @return [:enabled, :disabled, nil] Desired state of the feature
13
+ # @return [:enabled, :disabled, nil] Desired state of the feature.
14
14
  attribute :state
15
15
  validates :state, inclusion: {:in=>[:enabled, :disabled], :message=>"%{value} needs to be :enabled, :disabled"}, allow_nil: true
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module Ansible
2
2
  module Ruby
3
- VERSION = '1.0.4'.freeze
3
+ VERSION = '1.0.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansible-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brady Wied
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-05 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -75,7 +75,8 @@ files:
75
75
  - lib/ansible/ruby/modules/custom/commands/raw.rb
76
76
  - lib/ansible/ruby/modules/custom/commands/script.rb
77
77
  - lib/ansible/ruby/modules/custom/commands/shell.rb
78
- - lib/ansible/ruby/modules/custom/free_form.rb
78
+ - lib/ansible/ruby/modules/custom/utilities/include_vars.rb
79
+ - lib/ansible/ruby/modules/free_form.rb
79
80
  - lib/ansible/ruby/modules/generated/core/cloud/amazon/cloudformation.rb
80
81
  - lib/ansible/ruby/modules/generated/core/cloud/amazon/ec2.rb
81
82
  - lib/ansible/ruby/modules/generated/core/cloud/amazon/ec2_ami.rb