foreman_ansible_core 4.0.0 → 4.1.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 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cc5b524830b6cf92b7715fdc19d9bc65e9e863b247ecb3dbe2f35aa7c8ee4e46
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e3c669c0942e9d128d24ba4ffcf8896c9602d69058e286d1398dd531edd73ebf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c037f11562f8a20db823fefec5d9ffbc1aef49aa3a445fe78555acbc2ded7a84fea2863cfb1e88cb04ef8d11e93ad51b9700e6f81dedec1987e63e7677134125
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: dc1dce5cc48e298bee1708f9bfef4f20d86423860ac7761ea440b179ce3e4a44f70ef65aabee9299a95bae4e0a99640602e007035fcbca53ed62900951a17f37
         
     | 
| 
         @@ -8,9 +8,12 @@ module ForemanAnsibleCore 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  def initialize(input, suspended_action:)
         
     | 
| 
       9 
9 
     | 
    
         
             
                    super input, :suspended_action => suspended_action
         
     | 
| 
       10 
10 
     | 
    
         
             
                    @inventory = rebuild_secrets(rebuild_inventory(input), input)
         
     | 
| 
       11 
     | 
    
         
            -
                     
     | 
| 
      
 11 
     | 
    
         
            +
                    action_input = input.values.first[:input][:action_input]
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @playbook = action_input[:script]
         
     | 
| 
       12 
13 
     | 
    
         
             
                    @root = working_dir
         
     | 
| 
       13 
     | 
    
         
            -
                    @verbosity_level =  
     | 
| 
      
 14 
     | 
    
         
            +
                    @verbosity_level = action_input[:verbosity_level]
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @rex_command = action_input[:remote_execution_command]
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @check_mode = action_input[:check_mode]
         
     | 
| 
       14 
17 
     | 
    
         
             
                  end
         
     | 
| 
       15 
18 
     | 
    
         | 
| 
       16 
19 
     | 
    
         
             
                  def start
         
     | 
| 
         @@ -104,7 +107,10 @@ module ForemanAnsibleCore 
     | 
|
| 
       104 
107 
     | 
    
         
             
                  end
         
     | 
| 
       105 
108 
     | 
    
         | 
| 
       106 
109 
     | 
    
         
             
                  def start_ansible_runner
         
     | 
| 
       107 
     | 
    
         
            -
                     
     | 
| 
      
 110 
     | 
    
         
            +
                    env = {}
         
     | 
| 
      
 111 
     | 
    
         
            +
                    env['FOREMAN_CALLBACK_DISABLE'] = '1' if @rex_command
         
     | 
| 
      
 112 
     | 
    
         
            +
                    command = [env, 'ansible-runner', 'run', @root, '-p', 'playbook.yml']
         
     | 
| 
      
 113 
     | 
    
         
            +
                    command << '--cmdline' << '"--check"' if check_mode?
         
     | 
| 
       108 
114 
     | 
    
         
             
                    command << verbosity if verbose?
         
     | 
| 
       109 
115 
     | 
    
         
             
                    initialize_command(*command)
         
     | 
| 
       110 
116 
     | 
    
         
             
                    logger.debug("[foreman_ansible] - Running command '#{command.join(' ')}'")
         
     | 
| 
         @@ -118,6 +124,10 @@ module ForemanAnsibleCore 
     | 
|
| 
       118 
124 
     | 
    
         
             
                    @verbosity_level.to_i.positive?
         
     | 
| 
       119 
125 
     | 
    
         
             
                  end
         
     | 
| 
       120 
126 
     | 
    
         | 
| 
      
 127 
     | 
    
         
            +
                  def check_mode?
         
     | 
| 
      
 128 
     | 
    
         
            +
                    @check_mode == true
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       121 
131 
     | 
    
         
             
                  def prepare_directory_structure
         
     | 
| 
       122 
132 
     | 
    
         
             
                    inner = %w[inventory project].map { |part| File.join(@root, part) }
         
     | 
| 
       123 
133 
     | 
    
         
             
                    ([@root] + inner).each do |path|
         
     | 
| 
         @@ -138,7 +148,12 @@ module ForemanAnsibleCore 
     | 
|
| 
       138 
148 
     | 
    
         
             
                    action_inputs = input.values.map { |hash| hash[:input][:action_input] }
         
     | 
| 
       139 
149 
     | 
    
         
             
                    hostnames = action_inputs.map { |hash| hash[:name] }
         
     | 
| 
       140 
150 
     | 
    
         
             
                    inventories = action_inputs.map { |hash| hash[:ansible_inventory] }
         
     | 
| 
       141 
     | 
    
         
            -
                    host_vars = inventories.map { |i| i['_meta']['hostvars'] }.reduce( 
     | 
| 
      
 151 
     | 
    
         
            +
                    host_vars = inventories.map { |i| i['_meta']['hostvars'] }.reduce({}) do |acc, hosts|
         
     | 
| 
      
 152 
     | 
    
         
            +
                      hosts.reduce(acc) do |inner_acc, (hostname, vars)|
         
     | 
| 
      
 153 
     | 
    
         
            +
                        vars[:ansible_ssh_private_key_file] ||= ForemanRemoteExecutionCore.settings[:ssh_identity_key_file]
         
     | 
| 
      
 154 
     | 
    
         
            +
                        inner_acc.merge(hostname => vars)
         
     | 
| 
      
 155 
     | 
    
         
            +
                      end
         
     | 
| 
      
 156 
     | 
    
         
            +
                    end
         
     | 
| 
       142 
157 
     | 
    
         | 
| 
       143 
158 
     | 
    
         
             
                    { '_meta' => { 'hostvars' => host_vars },
         
     | 
| 
       144 
159 
     | 
    
         
             
                      'all' => { 'hosts' => hostnames,
         
     | 
| 
         @@ -17,6 +17,12 @@ module ForemanAnsibleCore 
     | 
|
| 
       17 
17 
     | 
    
         
             
                    Runner::AnsibleRunner
         
     | 
| 
       18 
18 
     | 
    
         
             
                  end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
                  # Discard everything apart from hostname to be able to tell the actions
         
     | 
| 
      
 21 
     | 
    
         
            +
                  # apart when debugging
         
     | 
| 
      
 22 
     | 
    
         
            +
                  def transform_input(input)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    { 'action_input' => input['action_input'].slice('name') }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       20 
26 
     | 
    
         
             
                  # def self.input_format
         
     | 
| 
       21 
27 
     | 
    
         
             
                  #   {
         
     | 
| 
       22 
28 
     | 
    
         
             
                  #     $UUID => {
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: foreman_ansible_core
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Daniel Lobato Garcia
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-05-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: foreman_remote_execution_core
         
     |