Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/167648
Change subject: Revert "Revert "trebuchet: derive the grain name from the repo
name""
......................................................................
Revert "Revert "trebuchet: derive the grain name from the repo name""
This reverts commit 8b602c08df041a369b0408a81f894d6b33cf07a2.
Change-Id: Iec445438f18e6e3c14e2d08dcb08a177f7dd6c80
---
M manifests/role/deployment.pp
M modules/deployment/files/modules/deploy.py
M modules/deployment/files/runners/deploy.py
M modules/deployment/manifests/salt_master.pp
D modules/deployment/templates/deploy_runner.conf.erb
M modules/trebuchet/lib/puppet/provider/package/trebuchet.rb
6 files changed, 17 insertions(+), 84 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/48/167648/1
diff --git a/manifests/role/deployment.pp b/manifests/role/deployment.pp
index 101823d..280c20a 100644
--- a/manifests/role/deployment.pp
+++ b/manifests/role/deployment.pp
@@ -5,127 +5,100 @@
class role::deployment::config {
$repo_config = {
'integration/kss' => {
- 'grain' => 'contint-production-slaves',
'upstream' => 'https://gerrit.wikimedia.org/r/integration/kss',
},
'integration/mediawiki-tools-codesniffer' => {
- 'grain' => 'contint-production-slaves',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/tools/codesniffer',
},
'integration/phpunit' => {
- 'grain' => 'contint-production-slaves',
'upstream' => 'https://gerrit.wikimedia.org/r/integration/phpunit',
},
'integration/phpcs' => {
- 'grain' => 'contint-production-slaves',
'upstream' => 'https://gerrit.wikimedia.org/r/integration/phpcs',
},
'integration/php-coveralls' => {
- 'grain' => 'contint-production-slaves',
'upstream' =>
'https://gerrit.wikimedia.org/r/integration/php-coveralls',
},
'integration/slave-scripts' => {
- 'grain' => 'contint-production-slaves',
'upstream' => 'https://gerrit.wikimedia.org/r/integration/jenkins',
'checkout_submodules' => true,
},
'gdash/gdash' => {
- 'grain' => 'gdash',
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/gdash',
},
'jobrunner/jobrunner' => {
- 'grain' => 'jobrunner',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/services/jobrunner',
'service_name' => 'jobrunner',
},
'grafana/grafana' => {
- 'grain' => 'grafana',
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/grafana',
},
'parsoid/deploy' => {
- 'grain' => 'parsoid',
'upstream' =>
'https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid/deploy',
'checkout_submodules' => true,
'service_name' => 'parsoid',
},
'eventlogging/EventLogging' => {
- 'grain' => 'eventlogging',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/extensions/EventLogging',
},
'ocg/ocg' => {
- 'grain' => 'ocg',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/services/ocg-collection',
'service_name' => 'ocg',
'checkout_submodules' => true,
},
'mathoid/mathoid' => {
- 'grain' => 'mathoid',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/services/mathoid',
'service_name' => 'mathoid',
'checkout_submodules' => true,
},
'citoid/deploy' => {
- 'grain' => 'citoid',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/services/citoid/deploy',
'service_name' => 'citoid',
'checkout_submodules' => true,
},
'rcstream/rcstream' => {
- 'grain' => 'rcstream',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/services/rcstream',
'service_name' => 'rcstream',
},
'fluoride/fluoride' => {
- 'grain' => 'eventlogging',
'upstream' =>
'https://gerrit.wikimedia.org/r/mediawiki/tools/fluoride',
},
'mwprof/mwprof' => {
- 'grain' => 'mwprof',
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/mwprof',
},
'reporter/reporter' => {
- 'grain' => 'reporter',
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/mwprof/reporter',
},
'test/testrepo' => {
- 'grain' => 'testrepo',
'service_name' => 'puppet',
'checkout_submodules' => true,
},
'elasticsearch/plugins' => {
- 'grain' => 'elasticsearchplugins',
'gitfat_enabled' => true,
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/elasticsearch/plugins',
},
'analytics/kraken/deploy' => {
- 'grain' => 'analytics-kraken-deploy',
'gitfat_enabled' => true,
'checkout_submodules' => true,
'upstream' =>
'https://gerrit.wikimedia.org/r/p/analytics/kraken/deploy',
},
'analytics/refinery' => {
- 'grain' => 'analytics-refinery',
'gitfat_enabled' => true,
'upstream' =>
'https://gerrit.wikimedia.org/r/analytics/refinery',
},
'scholarships/scholarships' => {
- 'grain' => 'scholarships',
'upstream' =>
'https://gerrit.wikimedia.org/r/wikimedia/wikimania-scholarships',
},
'librenms/librenms' => {
- 'grain' => 'librenms',
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/librenms',
},
'kibana/kibana' => {
- 'grain' => 'kibana',
'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/kibana',
},
'scap/scap' => {
- 'grain' => 'scap',
'upstream' => 'https://gerrit.wikimedia.org/r/mediawiki/tools/scap',
},
'servermon/servermon' => {
- 'grain' => 'servermon',
'service_name' => 'servermon',
},
'iegreview/iegreview' => {
diff --git a/modules/deployment/files/modules/deploy.py
b/modules/deployment/files/modules/deploy.py
index 7709a4f..7715848 100644
--- a/modules/deployment/files/modules/deploy.py
+++ b/modules/deployment/files/modules/deploy.py
@@ -267,9 +267,9 @@
status = 0
stats = {}
- for repo, config in repo_config.items():
+ for repo in repo_config:
# Ensure the minion is a deployment target for this repo
- if config['grain'] not in deployment_target:
+ if repo not in deployment_target:
continue
if repo not in stats:
stats[repo] = {}
diff --git a/modules/deployment/files/runners/deploy.py
b/modules/deployment/files/runners/deploy.py
index 9a5db48..5bfde5c 100755
--- a/modules/deployment/files/runners/deploy.py
+++ b/modules/deployment/files/runners/deploy.py
@@ -8,26 +8,11 @@
import yaml
-def __get_conf(repo, key):
- try:
- config = yaml.load(file('/etc/salt/deploy_runner.conf', 'r'))
- return config[key][repo]
- except IOError:
- return ''
- except yaml.YAMLError:
- return ''
- except KeyError:
- return ''
-
-
def fetch(repo):
'''
Fetch from a master, for the specified repo
'''
- grain = __get_conf(repo, 'deployment_repo_grains')
- if not grain:
- return "No grain defined for this repo."
- grain = "deployment_target:" + grain
+ grain = "deployment_target:" + repo
client = salt.client.LocalClient(__opts__['conf_file'])
cmd = 'deploy.fetch'
# comma in the tuple is a workaround for a bug in salt
@@ -41,10 +26,7 @@
'''
Checkout from a master, for the specified repo
'''
- grain = __get_conf(repo, 'deployment_repo_grains')
- if not grain:
- return "No grain defined for this repo."
- grain = "deployment_target:" + grain
+ grain = "deployment_target:" + repo
client = salt.client.LocalClient(__opts__['conf_file'])
cmd = 'deploy.checkout'
arg = (repo, reset)
@@ -58,10 +40,7 @@
Restart the service associated with this repo. If no service is associated
this call will do nothing.
'''
- grain = __get_conf(repo, 'deployment_repo_grains')
- if not grain:
- return "No grain defined for this repo."
- grain = "deployment_target:" + grain
+ grain = "deployment_target:" + repo
client = salt.client.LocalClient(__opts__['conf_file'])
cmd = 'deploy.restart'
# comma in the tuple is a workaround for a bug in salt
diff --git a/modules/deployment/manifests/salt_master.pp
b/modules/deployment/manifests/salt_master.pp
index d45706b..da117c4 100644
--- a/modules/deployment/manifests/salt_master.pp
+++ b/modules/deployment/manifests/salt_master.pp
@@ -8,14 +8,6 @@
$deployment_config
) {
- file { '/etc/salt/deploy_runner.conf':
- content => template('deployment/deploy_runner.conf.erb'),
- mode => '0444',
- owner => 'root',
- group => 'root',
- require => [Package['salt-master']],
- }
-
file { "${state_dir}/deploy":
ensure => directory,
mode => '0555',
diff --git a/modules/deployment/templates/deploy_runner.conf.erb
b/modules/deployment/templates/deploy_runner.conf.erb
deleted file mode 100644
index bc8ddd3..0000000
--- a/modules/deployment/templates/deploy_runner.conf.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<%
-_deployment_grains = {}
-@repo_config.each do |repo, config|
- _deployment_grains[repo] = config['grain']
-end
-%>deployment_repo_grains: {<% _deployment_grains.sort.each do |repo, grain|
%>'<%= repo %>': '<%= grain %>',<% end %>}
diff --git a/modules/trebuchet/lib/puppet/provider/package/trebuchet.rb
b/modules/trebuchet/lib/puppet/provider/package/trebuchet.rb
index 782ab98..9227069 100644
--- a/modules/trebuchet/lib/puppet/provider/package/trebuchet.rb
+++ b/modules/trebuchet/lib/puppet/provider/package/trebuchet.rb
@@ -41,20 +41,15 @@
[]
end
- def base
- @resource[:name].split('/').first
- end
-
def repo
- @resource[:name].split('/').last
- end
-
- def qualified_name
- [base, repo].join('/')
+ case @resource[:name]
+ when /\// then @resource[:name]
+ else ([@resource[:name]] * 2).join('/')
+ end
end
def target_path
- path = File.expand_path(File.join(self.class::BASE_PATH, qualified_name))
+ path = File.expand_path(File.join(self.class::BASE_PATH, repo))
unless path.length > self.class::BASE_PATH.length
fail Puppet::Error, "Target path '#{path}' is invalid."
end
@@ -103,7 +98,7 @@
# Return structured information about a particular package or `nil` if
# it is not installed.
def query
- return nil unless targets.include?(base)
+ return nil unless targets.include?(repo)
begin
tag = git('rev-parse', 'HEAD')
@@ -139,7 +134,7 @@
@cached_sha1 || begin
source = master
source = ('http://' + source) unless source.include?('://')
- source.gsub!(/\/?$/, "/#{qualified_name}/.git/deploy/deploy")
+ source.gsub!(/\/?$/, "/#{repo}/.git/deploy/deploy")
tag = open(source) { |raw| PSON.load(raw)['tag'] }
@cached_sha1 = resolve_tag(tag)
end
@@ -160,18 +155,18 @@
# Install a package. This ensures that the package is listed in the
# deployment_target grain and that it is checked out.
def install
- unless targets.include?(base)
- salt('grains.append', 'deployment_target', base)
+ unless targets.include?(repo)
+ salt('grains.append', 'deployment_target', repo)
salt_refresh!
end
- salt('deploy.fetch', qualified_name)
- salt('deploy.checkout', qualified_name)
+ salt('deploy.fetch', repo)
+ salt('deploy.checkout', repo)
end
# Remove a deployment target. This won't touch the Git repository
# on disk; it merely unsets the `deployment_target` grain value.
def uninstall
- salt('grains.remove', 'deployment_target', base)
+ salt('grains.remove', 'deployment_target', repo)
salt_refresh!
end
--
To view, visit https://gerrit.wikimedia.org/r/167648
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec445438f18e6e3c14e2d08dcb08a177f7dd6c80
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits