Thcipriani has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315139

Change subject: Scap: modify deploy-local arguments
......................................................................

Scap: modify deploy-local arguments

For scap to make fewer (possibly bad) assumptions about the environment
into which it is deploying more information needs be passed from the
command line arguments.

This change modifies any puppetized invocations of deploy-local to use
the new argument format.

This change will need to land along side the deployment of the scap
package that supports this change.

Bug: T146602
Change-Id: I4e0421b6ea6dda854998a59ef3165002ff022355
---
M modules/scap/lib/puppet/provider/package/scap3.rb
M modules/scap/manifests/target.pp
M modules/scap/spec/types/package/scap3_spec.rb
M modules/service/manifests/node.pp
M modules/service/templates/node/apply-config.sh.erb
5 files changed, 22 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/39/315139/1

diff --git a/modules/scap/lib/puppet/provider/package/scap3.rb 
b/modules/scap/lib/puppet/provider/package/scap3.rb
index 4a28799..45caf06 100644
--- a/modules/scap/lib/puppet/provider/package/scap3.rb
+++ b/modules/scap/lib/puppet/provider/package/scap3.rb
@@ -57,7 +57,7 @@
 
     uid = Etc.getpwnam(deploy_user).uid
 
-    execute([self.class.command(:scap), 'deploy-local', '--repo', repo_path, 
'-D', 'log_json:False'],
+    execute([self.class.command(:scap), 'deploy-local', '-D', 
'log_json:False', host_path, target_path],
             :uid => uid, :failonfail => true)
   end
 
@@ -124,6 +124,14 @@
     @deploy_user ||= install_option('owner', 'root')
   end
 
+  def host
+    @host_name ||= install_option('host', 'deployment.eqiad.wmnet')
+  end
+
+  def host_path
+    'http://' + File.join(host, repo_path)
+  end
+
   def repo
     resource[:name]
   end
diff --git a/modules/scap/manifests/target.pp b/modules/scap/manifests/target.pp
index 00a9955..853114e 100644
--- a/modules/scap/manifests/target.pp
+++ b/modules/scap/manifests/target.pp
@@ -87,14 +87,13 @@
         }
     }
 
-
+    $deployment_host = hiera('scap::deployment_server')
 
     if $::realm == 'labs' {
         if !defined(Security::Access::Config["scap-allow-${deploy_user}"]) {
             # Allow $deploy_user login from scap deployment host.
             # adds an exception in /etc/security/access.conf
             # to work around labs-specific restrictions
-            $deployment_host = hiera('scap::deployment_server')
             $deployment_ip = ipresolve($deployment_host, 4, $::nameservers[0])
             security::access::config { "scap-allow-${deploy_user}":
                 content  => "+ : ${deploy_user} : ${deployment_ip}\n",
@@ -104,8 +103,10 @@
     }
 
     package { $package_name:
-        install_options => [{
-                  owner => $deploy_user}],
+        install_options  => [{
+                  owner  => $deploy_user,
+                  host => $deployment_host,
+        }],
         provider        => 'scap3',
         require         => [Package['scap'], User[$deploy_user]],
     }
diff --git a/modules/scap/spec/types/package/scap3_spec.rb 
b/modules/scap/spec/types/package/scap3_spec.rb
index 82cf391..650dc03 100644
--- a/modules/scap/spec/types/package/scap3_spec.rb
+++ b/modules/scap/spec/types/package/scap3_spec.rb
@@ -28,8 +28,9 @@
     it 'should specify the right repo' do
       allow(FileUtils).to receive(:cd)
       expect(@provider).to receive(:execute).
-        with(['/usr/bin/scap', 'deploy-local', '--repo', 'foo/deploy', '-D', 
'log_json:False'],
-             uid: 666, failonfail: true)
+        with(['/usr/bin/scap', 'deploy-local', '-D', 'log_json:False',
+              'http://deployment.eqiad.wmnet/foo/deploy', 
'/srv/deployment/foo/deploy'],
+          uid: 666, failonfail: true)
       @provider.install
     end
   end
diff --git a/modules/service/manifests/node.pp 
b/modules/service/manifests/node.pp
index fb466fc..f2c66ba 100644
--- a/modules/service/manifests/node.pp
+++ b/modules/service/manifests/node.pp
@@ -272,6 +272,7 @@
         # the file and install its symlink
         $chown_user = "${deployment_user}:${deployment_user}"
         $chown_target = "/etc/${title}/config.yaml"
+        $deployment_host = hiera('scap::deployment_host')
         exec { "chown ${chown_target}":
             command => "/bin/chown ${chown_user} ${chown_target}",
             # perform the chown only if root is the effective owner
diff --git a/modules/service/templates/node/apply-config.sh.erb 
b/modules/service/templates/node/apply-config.sh.erb
index 5ae72d9..9437acd 100755
--- a/modules/service/templates/node/apply-config.sh.erb
+++ b/modules/service/templates/node/apply-config.sh.erb
@@ -3,5 +3,7 @@
 # Do not modify it manually
 
 set -e
-/usr/bin/scap deploy-local -D 'log_json:False' --repo <%= @repo %> --force 
config_deploy;
-<%- if @auto_refresh %>/usr/bin/scap deploy-local -D 'log_json:False' --repo 
<%= @repo %> --force restart_service;<%- end -%>
+/usr/bin/scap deploy-local -D 'log_json:False' --force config_deploy 
http://<%= @deployment_host %>/<%= @repo %> /srv/deployment/<%= @repo %>;
+<%- if @auto_refresh %>
+/usr/bin/scap deploy-local -D 'log_json:False' --force restart_service 
http://<%= @deployment_host %>/<%= @repo %> /srv/deployment/<%= @repo %>;
+<%- end -%>

-- 
To view, visit https://gerrit.wikimedia.org/r/315139
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e0421b6ea6dda854998a59ef3165002ff022355
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Thcipriani <tcipri...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to