Giuseppe Lavagetto has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/389473 )
Change subject: scap_source: also execute scap deploy --init
......................................................................
scap_source: also execute scap deploy --init
This is needed anyways in order to be able to actually deploy with scap,
so it makes sense to also run `scap deploy --init` when we check out the
repositories. This supersedes I473edc1c5454403
Change-Id: I254e6048bd8f24fc43e87082cd57c660cfa3c6ab
---
M modules/scap/lib/puppet/provider/scap_source/default.rb
1 file changed, 37 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/73/389473/1
diff --git a/modules/scap/lib/puppet/provider/scap_source/default.rb
b/modules/scap/lib/puppet/provider/scap_source/default.rb
index f401ed4..7e4846a 100644
--- a/modules/scap/lib/puppet/provider/scap_source/default.rb
+++ b/modules/scap/lib/puppet/provider/scap_source/default.rb
@@ -29,6 +29,7 @@
end
has_command(:git, '/usr/bin/git')
+ has_command(:scap, '/usr/bin/scap')
# Shortand for the repo name
def repo
@@ -105,6 +106,27 @@
}
end
+ def scap_init(path)
+ umask = 0o002
+ pwd = Etc.getpwnam(resource[:owner])
+ uid = pwd.uid
+ gid = pwd.gid
+ Dir.chdir(path) do
+ Puppet::Util.withumask(umask) {
+ Puppet::Util::Execution.execute(
+ [
+ self.class.command(:scap),
+ 'deploy',
+ '--init'
+ ],
+ :uid => uid,
+ :gid => gid,
+ :failonfail => true
+ )
+ }
+ end
+ end
+
def exists?
# check if the dirs exist; if they do, check
# if they're a git repo.
@@ -115,13 +137,18 @@
if resource[:ensure] == :present
begin
git('-C', target_path, 'rev-parse', 'HEAD')
- return true
rescue Puppet::ExecutionFailure
return false
end
+ # Also check that deploy-head is there, and return its value
+ deploy_head_exists?
else
- return true
+ true
end
+ end
+
+ def deploy_head_exists?
+ File.exists?(File.join(target_path, '.git', 'DEPLOY-HEAD'))
end
def create
@@ -133,13 +160,17 @@
end
# Checkout the main repository, and the scap one too
- Puppet.debug("Checking out #{repo} into #{target_path}")
- checkout repo, target_path
- Puppet.debug("Repository checked out in #{target_path}")
+ unless Dir.exists?(target_path)
+ Puppet.debug("Checking out #{repo} into #{target_path}")
+ checkout repo, target_path
+ Puppet.debug("Repository checked out in #{target_path}")
+ end
+
if resource[:scap_repository]
target = File.join(target_path, 'scap')
- checkout resource[:scap_repository], target
+ checkout resource[:scap_repository], target unless Dir.exists?(target)
end
+ scap_init unless deploy_head_exists?
end
def destroy
--
To view, visit https://gerrit.wikimedia.org/r/389473
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I254e6048bd8f24fc43e87082cd57c660cfa3c6ab
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits