hammer_cli_foreman_admin 0.0.5 → 0.0.10

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
- SHA1:
3
- metadata.gz: 3444c9174686c6251509442b79bd6f9d589e63f3
4
- data.tar.gz: 4017458e2f4c569852983f010b039936cf1f2ad3
2
+ SHA256:
3
+ metadata.gz: 30b52edc3139d699b7ca9cd9f3a9668597efbbdd43d3457f17b40f5aaf0b6331
4
+ data.tar.gz: ef5639aad2695e97da3da5c91d21280590aac2a83c180f45ba0a23a1fc31a32c
5
5
  SHA512:
6
- metadata.gz: e0bb55a1f660d53809fd281dd8c1a08b2532043b248c7f583e5de9a4a8412f213e889bb43d33c9ca56bb2bf95382e3015ac574bc304ee954f05e93c56cbde33a
7
- data.tar.gz: 59ea4d28f7425943078f14400f41617619d4185b6cd87881e7b1992964f036f8591550d0bf6eedb23705f59424404a0fe55e65b51340d274ad00be7ddb438e75
6
+ metadata.gz: 3fc58fc65ecfae667bd82bfb021627034eb593df34a20eaa0e1bd0ed5d35fd355b69edfc841db2e3b8f9792bb227d19ca28da4a94d1425a093a9aef0562fe7a9
7
+ data.tar.gz: 1f3ee1be6da582fd5588af60da3523e28392e71519dcd5cec5883696d32ed7d18c2c77522bec153aa3c9ed2363f772fd58d888b3cd2f6a5b0503b4a4f8b5700d
data/README.md CHANGED
@@ -1,4 +1,62 @@
1
1
  # Hammer CLI Foreman Admin
2
2
 
3
3
  Plugin for Hammer CLI for administrative tasks on the Foreman and Smart Proxy
4
- servers.
4
+ servers. Available sub-commands:
5
+
6
+ ## logging
7
+
8
+ Sets debug or normal (production) configuration options for all Foreman
9
+ components. To set debug level for all components:
10
+
11
+ # hammer admin logging --all --level-debug
12
+
13
+ To set production configuration:
14
+
15
+ # hammer admin logging --all --level-production
16
+
17
+ Available options:
18
+
19
+ # hammer admin logging --help
20
+ Usage:
21
+ hammer admin logging [OPTIONS]
22
+
23
+ Options:
24
+ --no-backup Skip configuration backups creation.
25
+ --prefix PATH Operate on prefixed environment (e.g. chroot).
26
+ -a, --all Apply to all components.
27
+ -c, --components COMPONENTS Components to apply, use --list to get them.
28
+ -d, --level-debug Increase verbosity level to debug.
29
+ -h, --help print help
30
+ -l, --list List available components.
31
+ -n, --dry-run Do not apply specified changes.
32
+ -p, --level-production Decrease verbosity level to standard.
33
+
34
+ Currently recognized components (files):
35
+
36
+ # hammer admin logging --list
37
+ -----------|-------------------------------------|-------------------------------------
38
+ COMPONENT | AUTO-DETECTED BY EXISTENCE OF | DESTINATIONS
39
+ -----------|-------------------------------------|-------------------------------------
40
+ postgresql | /var/lib/pgsql/data/postgresql.conf | syslog /var/lib/pgsql/data/pg_log/
41
+ rails | /etc/foreman/settings.yaml | /var/log/foreman/production.log
42
+ proxy | /etc/foreman-proxy/settings.yml | /var/log/foreman-proxy/proxy.log
43
+ puppet | /etc/puppet/puppet.conf | /var/log/puppet/masterhttp.log
44
+ dhcpd | /etc/dhcp/dhcpd.conf | syslog /var/log/dhcpd-debug.log
45
+ named | /etc/named.conf | syslog
46
+ tftp | /etc/xinetd.d/tftp | syslog
47
+ qpidd | /etc/qpid/qpidd.conf | syslog
48
+ tomcat | /etc/candlepin/candlepin.conf | /var/log/candlepin/ /var/log/tomcat/
49
+ pulp | /etc/pulp/server.conf | syslog /var/log/pulp-debug.log
50
+ virt-who | /etc/sysconfig/virt-who | syslog
51
+ -----------|-------------------------------------|-------------------------------------
52
+
53
+ The tool uses search and replace approach declared in YAML configuration files
54
+ `foreman_admin_logging_core.yml` and `foreman_admin_logging_katello.yml`.
55
+
56
+ ### Development
57
+
58
+ To test the logging subcommand, use the fixture examples and compare with git
59
+ diff:
60
+
61
+ PWD=$(pwd)
62
+ hammer -d admin logging --prefix $PWD/test/fixture_tree/ --no-backup -a -d
@@ -55,13 +55,15 @@
55
55
  -
56
56
  :action: ensure_line_is_present
57
57
  :line: [":log_level", ": ", "DEBUG"]
58
+ :join_with: ''
58
59
  :production:
59
60
  -
60
61
  :action: ensure_line_is_present
61
62
  :line: [":log_level", ": ", "ERROR"]
63
+ :join_with: ''
62
64
  -
63
65
  :name: puppet
64
- :friendly_name: Foreman Proxy
66
+ :friendly_name: Puppet Master 2.x+
65
67
  :file: /etc/puppet/puppet.conf
66
68
  :destinations: "/var/log/puppet/masterhttp.log"
67
69
  :services: ["apache2", "httpd"]
@@ -73,6 +75,20 @@
73
75
  -
74
76
  :action: ensure_line_is_present
75
77
  :line: ["log_level", "=", "notice"]
78
+ -
79
+ :name: puppet5
80
+ :friendly_name: Puppet Master 5.x+
81
+ :file: /etc/puppetlabs/puppetserver/logback.xml
82
+ :destinations: "/var/log/puppetlabs/puppetserver/puppetserver.log"
83
+ :services: ["puppetserver"]
84
+ :debug:
85
+ -
86
+ :action: ensure_line_is_present
87
+ :line: ['<root level', '=', '"debug">']
88
+ :production:
89
+ -
90
+ :action: ensure_line_is_present
91
+ :line: ['<root level', '=', '"info">']
76
92
  -
77
93
  :name: dhcpd
78
94
  :friendly_name: ISC DHCP
@@ -87,6 +103,7 @@
87
103
  -
88
104
  :action: ensure_line_is_present
89
105
  :line: ["log-facility", " ", "local6;"]
106
+ :join_with: ''
90
107
  :production:
91
108
  -
92
109
  :action: remove_file
@@ -15,10 +15,12 @@
15
15
  -
16
16
  :action: ensure_line_is_present
17
17
  :line: ["log-enable", "=", "info+"]
18
+ :join_with: ''
18
19
  :production:
19
20
  -
20
21
  :action: ensure_line_is_present
21
22
  :line: ["log-enable", "=", "error+"]
23
+ :join_with: ''
22
24
  -
23
25
  :name: tomcat
24
26
  :friendly_name: Candlepin
@@ -28,11 +30,11 @@
28
30
  :debug:
29
31
  -
30
32
  :action: ensure_line_is_present
31
- :line: ["log4j.logger.org.candlepin.servlet.filter", "=", "DEBUG"]
33
+ :line: ["log4j.logger.org.candlepin", "=", "DEBUG"]
32
34
  :production:
33
35
  -
34
36
  :action: ensure_line_is_present
35
- :line: ["log4j.logger.org.candlepin.servlet.filter", "=", "WARN"]
37
+ :line: ["log4j.logger.org.candlepin", "=", "WARN"]
36
38
  -
37
39
  :name: pulp
38
40
  :friendly_name: Pulp
@@ -47,6 +49,7 @@
47
49
  -
48
50
  :action: ensure_line_is_present
49
51
  :line: ["log_level", ": ", "DEBUG"]
52
+ :join_with: ''
50
53
  :production:
51
54
  -
52
55
  :action: remove_file
@@ -54,6 +57,7 @@
54
57
  -
55
58
  :action: ensure_line_is_present
56
59
  :line: ["log_level", ": ", "INFO"]
60
+ :join_with: ''
57
61
  -
58
62
  :name: virt-who
59
63
  :friendly_name: Virt-who utility
@@ -63,7 +67,9 @@
63
67
  -
64
68
  :action: ensure_line_is_present
65
69
  :line: ["VIRTWHO_DEBUG", "=", "1"]
70
+ :join_with: ''
66
71
  :production:
67
72
  -
68
73
  :action: ensure_line_is_present
69
74
  :line: ["VIRTWHO_DEBUG", "=", "0"]
75
+ :join_with: ''
@@ -61,7 +61,11 @@ module HammerCLIForemanAdmin
61
61
  if File.foreach(opts[:file]).grep(/#{opts[:line][0]}/).empty?
62
62
  open(opts[:file], 'a') { |f| f.puts "\n" + opts[:line].join }
63
63
  else
64
- run_command %Q|sed -i 's!#*#{opts[:line][0]}\s*#{opts[:line][1]}.*!#{opts[:line].join}!' #{opts[:file]}|
64
+ left = opts[:line][0]
65
+ mid = opts[:line][1]
66
+ join_with = opts[:join_with] || ' '
67
+ content = File.read(opts[:file]).gsub(/#* ?#{left}\s*#{mid}\s*.*$/, opts[:line].join(join_with))
68
+ open(opts[:file], "w") { |file| file << content }
65
69
  end
66
70
  end
67
71
  }
@@ -78,6 +82,11 @@ module HammerCLIForemanAdmin
78
82
  file = option_prefix + file if option_prefix
79
83
  backup_suffix = Time.now.utc.to_i.to_s(36)
80
84
  if File.exists?(file)
85
+ unless option_no_backup? || option_dry_run?
86
+ backup_file = "#{file}.#{backup_suffix}~"
87
+ logger.info "Creating backup #{backup_file}"
88
+ FileUtils.cp(file, backup_file)
89
+ end
81
90
  component[level].each do |action|
82
91
  action_name = action[:action]
83
92
  action[:name] = name
@@ -89,14 +98,7 @@ module HammerCLIForemanAdmin
89
98
  func = action_functions[action_name.to_sym]
90
99
  if func
91
100
  logger.info "Processing #{name} action #{action_name}"
92
- unless option_dry_run?
93
- unless option_no_backup?
94
- backup_file = "#{file}.#{backup_suffix}~"
95
- logger.info "Creating backup #{backup_file}"
96
- FileUtils.cp(file, backup_file)
97
- end
98
- func.call(action)
99
- end
101
+ func.call(action) unless option_dry_run?
100
102
  else
101
103
  raise "Unknown action #{action_name} for component #{name}"
102
104
  end
@@ -126,7 +128,7 @@ module HammerCLIForemanAdmin
126
128
  if option_all?
127
129
  components = configuration
128
130
  else
129
- raise("Unknown component provided, use --list to find them") unless option_components.all? { |c| available_components.include? c }
131
+ raise("Unknown component provided, use --list to find them") unless option_components.all? { |c| available_components.map{|x| x[:name]}.include? c }
130
132
  components = configuration.select{ |x| option_components.include? x[:name] }
131
133
  end
132
134
  components.each { |component| configure_component(component, new_level) }
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanAdmin
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.5'
3
+ @version ||= Gem::Version.new '0.0.10'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Zapletal
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli
@@ -49,7 +49,7 @@ homepage: https://github.com/theforeman/hammer-cli-foreman-admin
49
49
  licenses:
50
50
  - GPL-3
51
51
  metadata: {}
52
- post_install_message:
52
+ post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
@@ -64,9 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubyforge_project:
68
- rubygems_version: 2.5.1
69
- signing_key:
67
+ rubygems_version: 3.1.4
68
+ signing_key:
70
69
  specification_version: 4
71
70
  summary: Foreman administrative commands plugin
72
71
  test_files: []