Browse Source

Do not change mcollective config

The idea is to stop changing mcollective config and restarting it from
nailgun agent. This causes a lot of problems related to mcollective
config restarted at wrong time. From now at the bootstrap stage
mcollective is expected to be configured and started by startup scripts
while in bootstrap and by cloud-init at first boot into provisioned
node.

Change-Id: Ic8e31d6381d8ffb8f7fdfd1aa8ebc655bb4535ec
Partial-Bug: #1585671
Depends-On: Ia2f984570b38642b1090f6483ed3fa78958550c5
Georgy Kibardin 2 years ago
parent
commit
b33cfab5c3
1 changed files with 0 additions and 66 deletions
  1. 0
    66
      agent

+ 0
- 66
agent View File

@@ -79,59 +79,6 @@ def createsig(body)
79 79
   Digest::SHA1.hexdigest( digest body )
80 80
 end
81 81
 
82
-class McollectiveConfig
83
-  def initialize(logger)
84
-    @logger = logger
85
-    @configfile = '/etc/mcollective/server.cfg'
86
-  end
87
-
88
-  def get_config_by_key(find_key)
89
-    found_key = nil
90
-    found_value = nil
91
-    # This code is from mcollective's sources
92
-    File.open(@configfile, "r").each do |line|
93
-      # strip blank spaces, tabs etc off the end of all lines
94
-      line.gsub!(/\s*$/, "")
95
-      unless line =~ /^#|^$/
96
-        if line =~ /(.+?)\s*=\s*(.+)/
97
-          key = $1
98
-          val = $2
99
-          if key == find_key
100
-            found_key = key
101
-            found_value = val
102
-          end
103
-        end
104
-      end
105
-    end
106
-
107
-    found_value if found_key
108
-  end
109
-
110
-  def replace_identity(new_id)
111
-    # check if id complies reqs
112
-    raise 'Identities can only match /\w\.\-/' unless new_id.to_s.match(/^[\w\.\-]+$/)
113
-
114
-    value_from_config = get_config_by_key('identity')
115
-
116
-    if value_from_config == new_id.to_s
117
-      @logger.info "MCollective is up to date with identity = #{new_id}"
118
-    else
119
-      config = File.open(@configfile, "rb").read
120
-      if value_from_config
121
-        # Key found, but it has other value
122
-        @logger.info "Replacing identity in mcollective server.cfg to new value = '#{new_id}'"
123
-        config.gsub!(/^identity[ =].*$/, "identity = #{new_id}")
124
-        File.open(@configfile, "w") { |f| f.write(config) }
125
-      else # if key was not found
126
-        config += "\nidentity = #{new_id}\n"
127
-        @logger.info "Identity in mcollective server.cfg has not been found. Setting to '#{new_id}'"
128
-        File.open(@configfile, "w") { |f| f.write(config) }
129
-      end
130
-      puts `service mcollective restart`
131
-    end
132
-  end
133
-end
134
-
135 82
 class Offloading
136 83
   def initialize(name, sub)
137 84
     @name, @sub = name, sub
@@ -1403,10 +1350,6 @@ def write_data_to_file(logger, filename, data)
1403 1350
   end
1404 1351
 end
1405 1352
 
1406
-def provisioned?
1407
-  Socket.gethostname != 'bootstrap'
1408
-end
1409
-
1410 1353
 dry_run = false
1411 1354
 OptionParser.new do |opts|
1412 1355
   opts.banner = "Usage: nailgun-agent [options]"
@@ -1432,11 +1375,6 @@ unless dry_run
1432 1375
   sleep(sleep_time)
1433 1376
 end
1434 1377
 
1435
-if File.exist?('/etc/nailgun-agent/nodiscover')
1436
-  logger.info("Discover prevented by /etc/nailgun-agent/nodiscover presence.")
1437
-  exit 1
1438
-end
1439
-
1440 1378
 agent = NodeAgent.new(logger, dry_run)
1441 1379
 agent.update_state
1442 1380
 
@@ -1465,10 +1403,6 @@ begin
1465 1403
     exit 1
1466 1404
   end
1467 1405
   new_id = JSON.parse(resp.body)['id']
1468
-  mc_config = McollectiveConfig.new(logger)
1469
-  unless provisioned?
1470
-    mc_config.replace_identity(new_id)
1471
-  end
1472 1406
   write_data_to_file(logger, '/etc/nailgun_uid', new_id.to_s)
1473 1407
 rescue => ex
1474 1408
   # NOTE(mihgen): There is no need to retry - cron will do it for us

Loading…
Cancel
Save