foreman_vault 3.0.0 → 4.0.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: f4fbc008315206c64c8641835e56d14ef1b31f42ef411dfc321a3c8670998172
4
- data.tar.gz: 3ff7634135705a37592423d8d993790041b826a4d414f7952187290ae4d9109b
3
+ metadata.gz: 3740f896bbaf5c359055e38306c07e32880ed7caea04802e99f91aa11a5f0f7e
4
+ data.tar.gz: d3ce5deb29bd8e004daad91412af777815541e94816f11a7fed8f8db16a76c5e
5
5
  SHA512:
6
- metadata.gz: 9a7afc22a1db923534cd471d61b0837573c3f3db79c82ca7c6454148a281aa1adf76806fec9a39da3e4bb189e00a38ba2e3bf0e69382c48319489e24c943381d
7
- data.tar.gz: 34e80dcc58fcf00a8673d6ca9a5f23f30196d5d8ab38640d34eb4323322572ad152f66b308e252d2a2be9d176082193a9acbc4e62006016f279c218841a319fd
6
+ metadata.gz: 12b5e1377c8e2d85c03b9fc205225b337e2ea21e9a12d9179452e9dd94ec42c17475f671020553026a63c8054c35a83e684748df4f26f74925a7100018de2c95
7
+ data.tar.gz: 40db8b1479b9ff768c8de84119e9b4c81871bfcc66b3f0853f9872d73be311d8d279db33e79cf62af522e1802f75e9d450dceb3b0a4351f09f427f9730e174b6
data/README.md CHANGED
@@ -22,6 +22,7 @@ This allows Foreman to create everything needed to access Hashicorp Vault direct
22
22
 
23
23
  | Foreman Version | Plugin Version |
24
24
  | --------------- | -------------- |
25
+ | >= 3.19 | ~> 4.0 |
25
26
  | >= 3.13 | ~> 3.0 |
26
27
  | >= 3.9 | ~> 2.0 |
27
28
  | >= 2.3 | ~> 1.0 |
@@ -15,8 +15,9 @@ module ForemanVault
15
15
 
16
16
  initializer 'foreman_vault.register_plugin', before: :finisher_hook do |app|
17
17
  app.reloader.to_prepare do
18
+ require 'foreman/cron'
18
19
  Foreman::Plugin.register :foreman_vault do
19
- requires_foreman '>= 3.13'
20
+ requires_foreman '>= 3.19'
20
21
 
21
22
  apipie_documented_controllers ["#{ForemanVault::Engine.root}/app/controllers/api/v2/*.rb"]
22
23
 
@@ -53,6 +54,11 @@ module ForemanVault
53
54
  type: :boolean,
54
55
  description: N_('Enable or disable the Vault orchestration step for managing policies and auth methods'),
55
56
  default: false)
57
+ setting('vault_cronjobs_enabled',
58
+ full_name: N_('Vault Cronjobs enabled'),
59
+ type: :boolean,
60
+ description: N_('Enable or disable the hourly Vault Cronjobs for managing policies and auth methods'),
61
+ default: false)
56
62
  end
57
63
  end
58
64
 
@@ -60,6 +66,10 @@ module ForemanVault
60
66
  menu :top_menu, :vault_connections, url_hash: { controller: :vault_connections, action: :index },
61
67
  caption: N_('Vault Connections'),
62
68
  parent: :infrastructure_menu
69
+
70
+ # Register recurring task with Foreman::Cron framework
71
+ Foreman::Cron.register(:hourly, 'foreman_vault:policies:push')
72
+ Foreman::Cron.register(:hourly, 'foreman_vault:auth_methods:push')
63
73
  end
64
74
  end
65
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanVault
4
- VERSION = '3.0.0'
4
+ VERSION = '4.0.0'
5
5
  end
@@ -8,6 +8,7 @@ namespace :foreman_vault do # rubocop:disable Metrics/BlockLength
8
8
  desc 'Push auth methods for all hosts to Vault'
9
9
  task push: :environment do
10
10
  User.as_anonymous_admin do
11
+ next unless Setting['vault_cronjobs_enabled']
11
12
  hosts = Host::Managed.where(managed: true)
12
13
 
13
14
  hosts.each_with_index do |host, index|
@@ -28,6 +29,7 @@ namespace :foreman_vault do # rubocop:disable Metrics/BlockLength
28
29
  desc 'Push policies for all hosts to Vault'
29
30
  task push: :environment do
30
31
  User.as_anonymous_admin do
32
+ next unless Setting['vault_cronjobs_enabled']
31
33
  hosts = Host::Managed.where(managed: true)
32
34
 
33
35
  hosts.each_with_index do |host, index|
@@ -18,6 +18,8 @@ module ForemanVault
18
18
 
19
19
  FactoryBot.create(:parameter, name: 'vault_connection', value: vault_connection.name)
20
20
 
21
+ Setting[:vault_cronjobs_enabled] = true
22
+
21
23
  ForemanVault::VaultAuthMethod.any_instance.stubs(:vault_policy_name).returns('vault_policy_name')
22
24
  ForemanVault::VaultAuthMethod.any_instance.stubs(:certificate).returns('cert')
23
25
 
@@ -45,5 +47,16 @@ module ForemanVault
45
47
 
46
48
  assert_match("[1/1] Failed to push \"#{host.name}\"", stdout)
47
49
  end
50
+
51
+ it 'does not push auth methods when cronjobs are disabled' do
52
+ Setting[:vault_cronjobs_enabled] = false
53
+ host
54
+
55
+ stdout, _stderr = capture_io do
56
+ Rake::Task[TASK_NAME].invoke
57
+ end
58
+
59
+ assert_empty stdout
60
+ end
48
61
  end
49
62
  end
@@ -18,6 +18,8 @@ module ForemanVault
18
18
 
19
19
  FactoryBot.create(:parameter, name: 'vault_connection', value: vault_connection.name)
20
20
 
21
+ Setting[:vault_cronjobs_enabled] = true
22
+
21
23
  ForemanVault::VaultPolicy.any_instance.stubs(:name).returns('vault_policy_name')
22
24
  ForemanVault::VaultPolicy.any_instance.stubs(:rules).returns('rules')
23
25
 
@@ -45,5 +47,16 @@ module ForemanVault
45
47
 
46
48
  assert_match("[1/1] Failed to push \"#{host.name}\"", stdout)
47
49
  end
50
+
51
+ it 'does not push policies when cronjobs are disabled' do
52
+ Setting[:vault_cronjobs_enabled] = false
53
+ host
54
+
55
+ stdout, _stderr = capture_io do
56
+ Rake::Task[TASK_NAME].invoke
57
+ end
58
+
59
+ assert_empty stdout
60
+ end
48
61
  end
49
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dmTECH GmbH
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubygems_version: 3.6.7
142
+ rubygems_version: 4.0.20
143
143
  specification_version: 4
144
144
  summary: Adds support for using credentials from Hashicorp Vault
145
145
  test_files: