hammer_cli_foreman_admin 0.0.5 → 0.0.6

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: 3444c9174686c6251509442b79bd6f9d589e63f3
4
- data.tar.gz: 4017458e2f4c569852983f010b039936cf1f2ad3
3
+ metadata.gz: 35f546798245fb19fd29c1a04dc2d0c98c013917
4
+ data.tar.gz: 89fea9d3c7d1005cadbf784ddd8b8c0b489bacff
5
5
  SHA512:
6
- metadata.gz: e0bb55a1f660d53809fd281dd8c1a08b2532043b248c7f583e5de9a4a8412f213e889bb43d33c9ca56bb2bf95382e3015ac574bc304ee954f05e93c56cbde33a
7
- data.tar.gz: 59ea4d28f7425943078f14400f41617619d4185b6cd87881e7b1992964f036f8591550d0bf6eedb23705f59424404a0fe55e65b51340d274ad00be7ddb438e75
6
+ metadata.gz: 3410d055dea3f2f073a06e7acff85e01f9cc4e48c068ce4f1b071b3f15a3febe7ff7d5549081063712b3ff7b0633002a596cfa17d6b17b5e2a210e52806c21aa
7
+ data.tar.gz: e73d1b9bd51296479a2f4b840cf6662641bb9d250fe9c1a155717fe837a94d70a884b6bf789fb38c09c249213257f0fa9d039a8cb436fb6c0f20d4af558a87c0
data/README.md CHANGED
@@ -1,4 +1,54 @@
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`.
@@ -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
+ right = opts[:line][2]
67
+ content = File.read(opts[:file]).gsub(/#*#{left}\s*#{mid}\s*.*$/, opts[:line].join(' '))
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
@@ -87,16 +96,9 @@ module HammerCLIForemanAdmin
87
96
  action[:file] = file
88
97
  end
89
98
  func = action_functions[action_name.to_sym]
90
- if func
99
+ if func && ! option_dry_run?
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)
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.6'
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Zapletal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2016-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli