summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/staltstack-example-server
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-16 16:08:08 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-16 16:24:56 +0900
commitaeeba1d69f0498808252d5555b06b8fb6cae9269 (patch)
treee2fedca5c0231237d6d5c853b8e9aa81dde5d313 /saltstack-adapter/staltstack-example-server
parent3323c0829fa0492a5c7b3544a83cc24412c9934c (diff)
Saltstack sample server config doc
Issue-ID: CCSDK-361 Change-Id: I6a5407d7359dd84ea5fb71d5c7fab417abd31c55 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'saltstack-adapter/staltstack-example-server')
-rw-r--r--saltstack-adapter/staltstack-example-server/README30
-rw-r--r--saltstack-adapter/staltstack-example-server/README.md189
-rw-r--r--saltstack-adapter/staltstack-example-server/Vagrantfile-sample69
-rw-r--r--saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml34
-rw-r--r--saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml26
5 files changed, 318 insertions, 30 deletions
diff --git a/saltstack-adapter/staltstack-example-server/README b/saltstack-adapter/staltstack-example-server/README
deleted file mode 100644
index 687f52d30..000000000
--- a/saltstack-adapter/staltstack-example-server/README
+++ /dev/null
@@ -1,30 +0,0 @@
-'''
-/*-
-* ============LICENSE_START=======================================================
-* ONAP : APPC
-* ================================================================================
-* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-* ================================================================================
-* Copyright (C) 2017 Amdocs
-* =============================================================================
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* ECOMP is a trademark and service mark of AT&T Intellectual Property.
-* ============LICENSE_END=========================================================
-*/
-'''
-
-============
-INSTALLATION:
-============
-TODO: Instruction to build saltstack and enable SSH for adaptor communication. \ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/README.md b/saltstack-adapter/staltstack-example-server/README.md
new file mode 100644
index 000000000..beaf32f42
--- /dev/null
+++ b/saltstack-adapter/staltstack-example-server/README.md
@@ -0,0 +1,189 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Copyright (C) 2017 Amdocs
+* =============================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+* ============LICENSE_END=========================================================
+*/
+'''
+
+<CREATING saltstack environment is outside the scope of this adaptor, however the requirement is as follows>
+a. The SaltStack server should have it’s SSH enabled.
+b. Via ssh user account we should have the access to run saltstack command (here we will see how to enable root access via ssh and connect to server via root user).
+============
+INSTALLATION: Saltstack DEMO Environment creation:
+============
+
+1, Install VirtualBox.
+2, Install Vagrant.
+3, Download https://github.com/UtahDave/salt-vagrant-demo. You can use git or download a zip of the project directly from GitHub (sample Vagrant attached).
+4, Extract the zip file you downloaded, and then open a command prompt to the extracted directory.
+5, Run vagrant up to start the demo environment: vagrant up
+ After Vagrant ups (~10 minutes) and you are back at the command prompt, you are ready to continue.
+ More info: https://docs.saltstack.com/en/getstarted/fundamentals/
+
+============
+Configuration: Sample Saltstack server execution configuration requirement.
+============
+1, login to Master Saltstack server node:
+"sudo vi /etc/ssh/sshd_config" and SET the following
+PermitEmptyPasswords yes
+PermitRootLogin yes
+
+SAVE and close.
+
+2, Run: "sudo passwd root"
+and set the root password.
+Then run: "sudo reboot"
+
+3, On the host machine, open the virtual box set a port forwarding to the master server for 2222 -> 22
+This will redirect messages to host machine to the Vagarant Master server.
+
+============
+TESTING: Sample Saltstack server command execution.
+============
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessReal() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "127.0.0.1");
+ params.put("Port", "22");
+ params.put("User", "sdn");
+ params.put("Password", "foo");
+ params.put("Id", "test1");
+ params.put("cmd", "ls -l");
+ params.put("slsExec", "false");
+ params.put("execTimeout", "12000");
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("250", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if local ssh is not enabled
+ return;
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessRealCommand() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "<IP address of SS server>");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("cmd", "cd /srv/salt/; salt '*' state.apply vim --out=json --static");
+ params.put("slsExec", "true");
+ params.put("execTimeout", "12000");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ return;
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessRealSSL() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "10.251.92.17");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("slsName", "vim");
+ params.put("execTimeout", "12000");
+ params.put("applyTo", "minion1");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ return;
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessRealSSLNoApplyTo() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "10.251.92.17");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("slsName", "vim");
+ params.put("execTimeout", "12000");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ return;
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessSSLFile() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "10.251.92.17");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("execTimeout", "12000");
+ params.put("applyTo", "minion1");
+ params.put("slsFile", "src/test/resources/config.sls");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLSFile(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ return;
+ }
+ } \ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/Vagrantfile-sample b/saltstack-adapter/staltstack-example-server/Vagrantfile-sample
new file mode 100644
index 000000000..5fbcfbb74
--- /dev/null
+++ b/saltstack-adapter/staltstack-example-server/Vagrantfile-sample
@@ -0,0 +1,69 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+ os = "bento/ubuntu-16.04"
+ net_ip = "192.168.50"
+
+ config.vm.define :master, primary: true do |master_config|
+ master_config.vm.provider "virtualbox" do |vb|
+ vb.memory = "2048"
+ vb.cpus = 1
+ vb.name = "master"
+ end
+ master_config.vm.box = "#{os}"
+ master_config.vm.host_name = 'saltmaster.local'
+ master_config.vm.network "private_network", ip: "#{net_ip}.10"
+ master_config.vm.synced_folder "saltstack/salt/", "/srv/salt"
+ master_config.vm.synced_folder "saltstack/pillar/", "/srv/pillar"
+
+ master_config.vm.provision :salt do |salt|
+ salt.master_config = "saltstack/etc/master"
+ salt.master_key = "saltstack/keys/master_minion.pem"
+ salt.master_pub = "saltstack/keys/master_minion.pub"
+ salt.minion_key = "saltstack/keys/master_minion.pem"
+ salt.minion_pub = "saltstack/keys/master_minion.pub"
+ salt.seed_master = {
+ "minion1" => "saltstack/keys/minion1.pub",
+ "minion2" => "saltstack/keys/minion2.pub"
+ }
+
+ salt.install_type = "stable"
+ salt.install_master = true
+ salt.no_minion = true
+ salt.verbose = true
+ salt.colorize = true
+ salt.bootstrap_options = "-P -c /tmp"
+ end
+ end
+
+
+ [
+ ["minion1", "#{net_ip}.11", "1024", os ],
+ ["minion2", "#{net_ip}.12", "1024", os ],
+ ].each do |vmname,ip,mem,os|
+ config.vm.define "#{vmname}" do |minion_config|
+ minion_config.vm.provider "virtualbox" do |vb|
+ vb.memory = "#{mem}"
+ vb.cpus = 1
+ vb.name = "#{vmname}"
+ end
+ minion_config.vm.box = "#{os}"
+ minion_config.vm.hostname = "#{vmname}"
+ minion_config.vm.network "private_network", ip: "#{ip}"
+
+ minion_config.vm.provision :salt do |salt|
+ salt.minion_config = "saltstack/etc/#{vmname}"
+ salt.minion_key = "saltstack/keys/#{vmname}.pem"
+ salt.minion_pub = "saltstack/keys/#{vmname}.pub"
+ salt.install_type = "stable"
+ salt.verbose = true
+ salt.colorize = true
+ salt.bootstrap_options = "-P -c /tmp"
+ end
+ end
+ end
+ end \ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml b/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml
new file mode 100644
index 000000000..468d2a24b
--- /dev/null
+++ b/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml
@@ -0,0 +1,34 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Copyright (C) 2017 Amdocs
+# * =============================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# * ============LICENSE_END=========================================================
+# */
+
+my-vim:
+ git.latest:
+ - name: https://github.com/nbari/my-vim
+ - target: /usr/local/share/my-vim
+ - rev: master
+ - submodules: True
+ cmd.wait:
+ - name: 'cd /usr/local/share/my-vim; git submodule init; git submodule foreach git pull origin master; git submodule update'
+ - watch:
+ - git: my-vim \ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml b/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml
new file mode 100644
index 000000000..bcc7fda9a
--- /dev/null
+++ b/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml
@@ -0,0 +1,26 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Copyright (C) 2017 Amdocs
+# * =============================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# * ============LICENSE_END=========================================================
+# */
+
+vim:
+ pkg.installed