Add initial version of CI&CD apps

Change-Id: Ic2b4683f6ce4494cd88e2428dc30734f81233be7
This commit is contained in:
Anastasia Kuznetsova 2016-02-04 16:24:45 +03:00
parent 4712d31bc4
commit 2c94971dd0
40 changed files with 1318 additions and 0 deletions

40
.gitignore vendored Normal file
View File

@ -0,0 +1,40 @@
*.py[cod]
*.sqlite
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
.venv
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs
pip-log.txt
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.idea
.DS_Store
etc/*.conf
tools/lintstack.head.py
tools/pylint_exceptions
#Linux swap file
*.swp

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=gerrit.mirantis.com
port=29418
project=open-paas/open-paas.git

View File

@ -0,0 +1,99 @@
Namespaces:
=: io.murano.apps
std: io.murano
res: io.murano.resources
sys: io.murano.system
Name: Gerrit
Extends: std:Application
Properties:
name:
Contract: $.string().notNull()
warUrl:
Contract: $.string().notNull()
ldap:
Contract: $.class(OpenLDAP)
instance:
Contract: $.class(res:Instance).notNull()
Methods:
initialize:
Body:
- $._environment: $.find(std:Environment).require()
deploy:
Body:
- If: not $.getAttr(deployed, false)
Then:
- $securityGroupIngress:
- ToPort: 8080
FromPort: 8080
IpProtocol: tcp
External: true
- ToPort: 29418
FromPort: 29418
IpProtocol: tcp
External: true
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
- $._environment.reporter.report($this, 'Creating VM for Gerrit')
- $.instance.deploy()
- $resources: new(sys:Resources)
- $template: $resources.yaml('DeployGerrit.template').bind(dict(
warUrl => $.warUrl
))
- $._environment.reporter.report($this, 'Deploying Gerrit')
- $.instance.agent.call($template, $resources)
- If: $.ldap != null
Then:
- $._environment.reporter.report($this, 'Gerrit waits OpenLDAP to be deployed...')
- $.ldap.deploy()
- $.connectLDAP()
- $._environment.reporter.report($this, 'Gerrit is deployed!')
- $.setAttr(deployed, true)
connectLDAP:
Body:
- $._environment.reporter.report($this, 'Connecting Gerrit to OpenLDAP server')
- $ldapInstance: $.ldap.instance
- If: $ldapInstance.assignFloatingIp
Then:
- $ldapHost: $ldapInstance.floatingIpAddress
Else:
- $ldapHost: $ldapInstance.ipAddresses[0]
- $host: "localhost"
- If: $.instance.assignFloatingIp
Then:
- $host: $.instance.floatingIpAddress
Else:
- $host: $.instance.ipAddresses[0]
- $resources: new(sys:Resources)
- $template: $resources.yaml('ConnectLDAP.template').bind(dict(
openLDAPip => $ldapHost,
host => $host,
domain => $.ldap.domain
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, format('Gerrit is available at {0}:8080', $host))
putKey:
Arguments:
- sshKey:
Contract: $.string().notNull()
Body:
- $._environment.reporter.report($this, 'Put SSH key to Gerrit server')
- $resources: new(sys:Resources)
- $template: $resources.yaml('PutKey.template').bind(dict(
sshKey => $sshKey
))
- $.instance.agent.call($template, $resources)
destroy:
Body:
- $.reportDestroyed()
- $.setAttr(deployed, false)

View File

@ -0,0 +1,22 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Connect LDAP
Parameters:
openLDAPip: $openLDAPip
host: $host
domain: $domain
Body: |
return configure('{0} {1} {2}'.format(args.openLDAPip, args.host, args.domain)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: connectLDAP.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,20 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Deploy Gerrit
Parameters:
warUrl: $warUrl
Body: |
return deploy('{0}'.format(args.warUrl)).stdout
Scripts:
deploy:
Type: Application
Version: 1.0.0
EntryPoint: deployGerrit.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,19 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Put sshKey
Parameters:
sshKey: $sshKey
Body: |
return configure('{0}'.format(args.sshKey)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: putKey.sh
Files: []
Options:
captureStdout: true
captureStderr: true

View File

@ -0,0 +1,25 @@
#!/bin/bash
OPENLDAP_IP="$1"
HOST="$2"
DOMAIN="$3"
# parse tld
NAME="`echo "$DOMAIN" | cut -d. -f1`"
TLD="`echo "$DOMAIN" | cut -d. -f2`"
# setup gerrit to authenticate from OpenLDAP
sed -e "s/type = OPENID/type = ldap/" -i /home/gerrit/gerrit_testsite/etc/gerrit.config
sed -e "s,canonicalWebUrl.*,canonicalWebUrl = http://${HOST}:8080," -i /home/gerrit/gerrit_testsite/etc/gerrit.config
cat << EOF >> /home/gerrit/gerrit_testsite/etc/gerrit.config
[ldap]
server = ldap://${OPENLDAP_IP}
accountBase = OU=users,DC=${NAME},DC=${TLD}
username = CN=admin,DC=${NAME},DC=${TLD}
password = openstack
accountFullName = cn
EOF
# restart gerrit
sudo -u gerrit /home/gerrit/gerrit_testsite/bin/gerrit.sh restart

View File

@ -0,0 +1,22 @@
#!/bin/bash
WAR="$1"
# Update the packages and install git and java
apt-get update
apt-get install -y git openjdk-7-jdk git-review
# Create a user, gerrit2, to run gerrit
useradd -d/home/gerrit gerrit
mkdir /home/gerrit
chown -R gerrit:gerrit /home/gerrit
# Allow firewall holes for Gerrit
iptables -I INPUT 1 -p tcp -m tcp --dport 8080 -j ACCEPT -m comment --comment "by murano, Gerrit server access on HTTP on port 8080"
iptables -I INPUT 1 -p tcp -m tcp --dport 29418 -j ACCEPT -m comment --comment "by murano, server Apache server access via sshd on port 29418"
# Download latest stable code, install and remove war file.
cd /tmp
wget ${WAR}
filename=$(basename ${WAR})
sudo -u gerrit java -jar /tmp/$filename init --batch -d /home/gerrit/gerrit_testsite
rm /tmp/$filename

View File

@ -0,0 +1,9 @@
#!/bin/bash
SSHKEY="$1 $2"
mkdir /home/gerrit/.ssh
echo $SSHKEY > /home/gerrit/.ssh/authorized_keys
echo $SSHKEY > /home/gerrit/.ssh/jenkins-id_rsa.pub
chmod 700 /home/gerrit/.ssh
chmod 600 /home/gerrit/.ssh/authorized_keys /home/gerrit/.ssh/jenkins-id_rsa.pub
chown -R gerrit:gerrit /home/gerrit/.ssh

View File

@ -0,0 +1,93 @@
Version: 2
Application:
?:
type: io.murano.apps.Gerrit
name: $.appConfiguration.name
warUrl: $.appConfiguration.warUrl
ldap: $.appConfiguration.OpenLDAP
instance:
?:
type: io.murano.resources.LinuxMuranoInstance
name: generateHostname($.instanceConfiguration.unitNamingPattern, 1)
flavor: $.instanceConfiguration.flavor
image: $.instanceConfiguration.osImage
keyname: $.instanceConfiguration.keyPair
availabilityZone: $.instanceConfiguration.availabilityZone
assignFloatingIp: $.appConfiguration.assignFloatingIP
Forms:
- appConfiguration:
fields:
- name: name
type: string
label: Application Name
initial: Gerrit
description: >-
Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and
underline are allowed
- name: assignFloatingIP
type: boolean
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: true
required: false
- name: warUrl
type: string
label: URL for war
initial: http://gerrit-releases.storage.googleapis.com/gerrit-2.11.2.war
description: >-
Enter the war version from Gerrit's site
http://gerrit-releases.storage.googleapis.com/index.html
- name: OpenLDAP
type: io.murano.apps.OpenLDAP
required: false
description: >-
Specify OpenLDAP domain for authentication.
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
description: Specify some instance parameters on which the application would be created
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that application performance
depends on this parameter.
initial: m1.tiny
required: false
- name: osImage
type: image
imageType: linux
label: Instance image
description: >-
Select a valid image for the application. Image should already be prepared and
registered in glance.
- name: keyPair
type: keypair
label: Key Pair
description: >-
Select a Key Pair to control access to instances. You can login to
instances using this KeyPair after the deployment of application.
required: false
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where the application would be installed.
required: false
- name: unitNamingPattern
type: string
label: Instance Naming Pattern
required: false
maxLength: 200
regexpValidator: '^[-_\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
description: >-
Specify a string, that will be used in instance hostname.
Just A-Z, a-z, 0-9, dash and underline are allowed.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,13 @@
Format: 1.0
Type: Application
FullName: io.murano.apps.Gerrit
Name: Gerrit
Description: |
Gerrit is a web based code review system, facilitating online code reviews
for projects using the Git version control system.
Author: 'Mirantis, Inc'
Tags: [Server, Java, Gerrit, CI]
Classes:
io.murano.apps.Gerrit: Gerrit.yaml
UI: ui.yaml
Logo: logo.png

View File

@ -0,0 +1,155 @@
Namespaces:
=: io.murano.apps
std: io.murano
res: io.murano.resources
sys: io.murano.system
Name: Jenkins
Extends: std:Application
Properties:
name:
Contract: $.string().notNull()
ldap:
Contract: $.class(OpenLDAP)
gerrit:
Contract: $.class(Gerrit)
instance:
Contract: $.class(res:Instance).notNull()
Methods:
initialize:
Body:
- $._environment: $.find(std:Environment).require()
deploy:
Body:
- If: not $.getAttr(deployed, false)
Then:
- $._environment.reporter.report($this, 'Creating VM for Jenkins')
- $securityGroupIngress:
- ToPort: 8080
FromPort: 8080
IpProtocol: tcp
External: true
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
- $.instance.deploy()
- $resources: new(sys:Resources)
- $template: $resources.yaml('DeployJenkins.template')
- $._environment.reporter.report($this, 'Jenkins deploying')
- $.instance.agent.call($template, $resources)
- If: $.ldap != null
Then:
- $._environment.reporter.report($this, 'Jenkins waits OpenLDAP to be deployed...')
- $.ldap.deploy()
- $.connectLDAP()
- If: $.gerrit != null and $.ldap != null
Then:
- $._environment.reporter.report($this, 'Jenkins waits Gerrit to be deployed...')
- $.gerrit.deploy()
- $.connectGerrit()
- $sshKey: $.getKey()
- $.gerrit.putKey($sshKey)
- $.installJJB()
- $.configureJJB()
- $.createTestJob()
- If: $.instance.assignFloatingIp
Then:
- $host: $.instance.floatingIpAddress
Else:
- $host: $.instance.ipAddresses[0]
- $._environment.reporter.report($this, 'Jenkins is available at {0}:8080'.format($host))
- $.setAttr(deployed, true)
installJJB:
Body:
- $resources: new(sys:Resources)
- $._environment.reporter.report($this, 'Installing Jenkins Job Builder')
- $template: $resources.yaml('InstallJJB.template')
- $.instance.agent.call($template, $resources)
configureJJB:
Body:
- $resources: new(sys:Resources)
- $._environment.reporter.report($this, 'Configuring Jenkins Job Builder')
- If: $.ldap != null
Then:
- If: $.ldap.ldapUser != '' and $.ldap.ldapUser != null
Then:
- $user: $.ldap.ldapUser
- $password: $.ldap.ldapPass
Else:
- $user: 'jenkins'
- $password: 'openstack'
Else:
- $user: ''
- $password: ''
- $template: $resources.yaml('ConfigureJJB.template').bind(dict(
jenkinsip => $.instance.ipAddresses[0],
user => $user,
password => $password
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, 'Jenkins Job Builder is configured!')
createTestJob:
Body:
- $resources: new(sys:Resources)
- $._environment.reporter.report($this, 'Creating test job via Jenkins Job Builder')
- $template: $resources.yaml('CreateTestJob.template')
- $.instance.agent.call($template, $resources)
connectLDAP:
Body:
- $.ldap.configureOpenLDAPUser($.ldap.domain, 'jenkins', 'openstack')
- $ldapInstance: $.ldap.instance
- If: $ldapInstance.assignFloatingIp
Then:
- $ldapHost: $ldapInstance.floatingIpAddress
Else:
- $ldapHost: $ldapInstance.ipAddresses[0]
- $resources: new(sys:Resources)
- $._environment.reporter.report($this, 'Connecting Jenkins to OpenLDAP server')
- $template: $resources.yaml('ConnectLDAP.template').bind(dict(
openLDAPip => $ldapHost,
domain => $.ldap.domain
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, 'Jenkins is connected to OpenLDAP server!')
connectGerrit:
Body:
- $._environment.reporter.report($this, 'Connecting Jenkins with Gerrit')
- $gerritInstance: $.gerrit.instance
- If: $gerritInstance.assignFloatingIp
Then:
- $gerritHost: $gerritInstance.floatingIpAddress
Else:
- $gerritHost: $gerritInstance.ipAddresses[0]
- $resources: new(sys:Resources)
- $template: $resources.yaml('ConnectGerrit.template').bind(dict(
gerritIp => $gerritHost,
domain => $.ldap.domain
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, 'Jenkins is connected with Gerrit!')
getKey:
Body:
- $._environment.reporter.report($this, 'Get SSH key from Jenkins')
- $resources: new(sys:Resources)
- $template: $resources.yaml('GetKey.template')
- $sshKey: $.instance.agent.call($template, $resources)
- Return: format('{0}', $sshKey)
destroy:
Body:
- $.reportDestroyed()
- $.setAttr(deployed, false)

View File

@ -0,0 +1,22 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Configure Jenkins Job Builder
Parameters:
jenkinsip: $jenkinsip
user: $user
password: $password
Body: |
return configure('{0} {1} {2}'.format(args.jenkinsip, args.user, args.password)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: configureJJB.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,21 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Connect LDAP
Parameters:
gerritIp: $gerritIp
domain: $domain
Body: |
return configure('{0} {1}'.format(args.gerritIp, args.domain)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: connectGerrit.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,21 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Connect LDAP
Parameters:
openLDAPip: $openLDAPip
domain: $domain
Body: |
return configure('{0} {1}'.format(args.openLDAPip, args.domain)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: connectLDAP.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,17 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Create Test Job using Jenkins Job Builder
Body: |
return create().stdout
Scripts:
create:
Type: Application
Version: 1.0.0
EntryPoint: createTestJob.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,20 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Deploy Jenkins
Parameters:
appName: $appName
Body: |
return deploy(args.appName).stdout
Scripts:
deploy:
Type: Application
Version: 1.0.0
EntryPoint: deployJenkins.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,22 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Get ssh key
Parameters:
sshKey: $sshKey
Body: |
key = ''
with open('/var/lib/jenkins/.ssh/jenkins-id_rsa.pub','r') as f:
key = f.read()
return key
Scripts:
noop:
Type: Application
Version: 1.0.0
EntryPoint: noop.sh
Files: []
Options:
captureStdout: true
captureStderr: true

View File

@ -0,0 +1,17 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Install Jenkins Job Builder
Body: |
return deploy().stdout
Scripts:
deploy:
Type: Application
Version: 1.0.0
EntryPoint: installJJB.sh
Files: []
Options:
captureStdout: true
captureStderr: true
verifyExitcode: false

View File

@ -0,0 +1,18 @@
#!/bin/bash
JENKINS_IP="$1"
USER="$2"
PASSWORD="$3"
cd ~/jenkins-job-builder
cp etc/jenkins_jobs.ini-sample etc/jenkins_jobs.ini
sed -i "s/https:\/\/jenkins.example.com/http:\/\/$JENKINS_IP:8080\//g" etc/jenkins_jobs.ini
if [ -n "$USER" ];
then
sed -i "s/user=jenkins/user=$USER/g" etc/jenkins_jobs.ini;
sed -i "s/password=1234567890abcdef1234567890abcdef/password=$PASSWORD/g" etc/jenkins_jobs.ini;
fi

View File

@ -0,0 +1,117 @@
#!/bin/bash
GERRIT_IP="$1"
DOMAIN="$2"
cat << CONFIG >> /var/lib/jenkins/credentials.xml
<?xml version='1.0' encoding='UTF-8'?>
<com.cloudbees.plugins.credentials.SystemCredentialsProvider plugin="credentials@1.18">
<domainCredentialsMap class="hudson.util.CopyOnWriteMap\$Hash">
<entry>
<com.cloudbees.plugins.credentials.domains.Domain>
<specifications/>
</com.cloudbees.plugins.credentials.domains.Domain>
<java.util.concurrent.CopyOnWriteArrayList>
<com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey plugin="ssh-credentials@1.10">
<scope>GLOBAL</scope>
<id>10055155-5c33-4318-8161-96a3ccd270a8</id>
<description></description>
<username>jenkins</username>
<passphrase>aE53R1jYUuH1K2BgkbGqfw==</passphrase>
<privateKeySource class="com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey\$FileOnMasterPrivateKeySource">
<privateKeyFile>/var/lib/jenkins/.ssh/jenkins-id_rsa</privateKeyFile>
</privateKeySource>
</com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey>
</java.util.concurrent.CopyOnWriteArrayList>
</entry>
</domainCredentialsMap>
</com.cloudbees.plugins.credentials.SystemCredentialsProvider>
CONFIG
cat << CONFIG >> /var/lib/jenkins/gerrit-trigger.xml
<?xml version='1.0' encoding='UTF-8'?>
<com.sonyericsson.hudson.plugins.gerrit.trigger.PluginImpl plugin="gerrit-trigger@2.12.0">
<servers class="java.util.concurrent.CopyOnWriteArrayList">
<com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer>
<name>Gerrit</name>
<noConnectionOnStartup>false</noConnectionOnStartup>
<config class="com.sonyericsson.hudson.plugins.gerrit.trigger.config.Config">
<gerritHostName>${GERRIT_IP}</gerritHostName>
<gerritSshPort>29418</gerritSshPort>
<gerritProxy></gerritProxy>
<gerritUserName>jenkins</gerritUserName>
<gerritEMail>jenkins@${DOMAIN}</gerritEMail>
<gerritAuthKeyFile>/var/lib/jenkins/.ssh/jenkins-id_rsa</gerritAuthKeyFile>
<gerritAuthKeyFilePassword>aE53R1jYUuH1K2BgkbGqfw==</gerritAuthKeyFilePassword>
<useRestApi>false</useRestApi>
<restCodeReview>false</restCodeReview>
<restVerified>false</restVerified>
<gerritBuildCurrentPatchesOnly>false</gerritBuildCurrentPatchesOnly>
<gerritVerifiedCmdBuildSuccessful>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Successful &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildSuccessful>
<gerritVerifiedCmdBuildUnstable>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Unstable &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildUnstable>
<gerritVerifiedCmdBuildFailed>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Failed &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildFailed>
<gerritVerifiedCmdBuildStarted>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;Build Started &lt;BUILDURL&gt; &lt;STARTED_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildStarted>
<gerritVerifiedCmdBuildNotBuilt>gerrit review &lt;CHANGE&gt;,&lt;PATCHSET&gt; --message &apos;No Builds Executed &lt;BUILDS_STATS&gt;&apos; --verified &lt;VERIFIED&gt; --code-review &lt;CODE_REVIEW&gt;</gerritVerifiedCmdBuildNotBuilt>
<gerritFrontEndUrl>http://${GERRIT_IP}:8080/</gerritFrontEndUrl>
<gerritBuildStartedVerifiedValue>0</gerritBuildStartedVerifiedValue>
<gerritBuildStartedCodeReviewValue>0</gerritBuildStartedCodeReviewValue>
<gerritBuildSuccessfulVerifiedValue>1</gerritBuildSuccessfulVerifiedValue>
<gerritBuildSuccessfulCodeReviewValue>0</gerritBuildSuccessfulCodeReviewValue>
<gerritBuildFailedVerifiedValue>-1</gerritBuildFailedVerifiedValue>
<gerritBuildFailedCodeReviewValue>0</gerritBuildFailedCodeReviewValue>
<gerritBuildUnstableVerifiedValue>0</gerritBuildUnstableVerifiedValue>
<gerritBuildUnstableCodeReviewValue>-1</gerritBuildUnstableCodeReviewValue>
<gerritBuildNotBuiltVerifiedValue>0</gerritBuildNotBuiltVerifiedValue>
<gerritBuildNotBuiltCodeReviewValue>0</gerritBuildNotBuiltCodeReviewValue>
<enableManualTrigger>true</enableManualTrigger>
<enablePluginMessages>true</enablePluginMessages>
<buildScheduleDelay>3</buildScheduleDelay>
<dynamicConfigRefreshInterval>30</dynamicConfigRefreshInterval>
<categories class="linked-list">
<com.sonyericsson.hudson.plugins.gerrit.trigger.VerdictCategory>
<verdictValue>Code-Review</verdictValue>
<verdictDescription>Code Review</verdictDescription>
</com.sonyericsson.hudson.plugins.gerrit.trigger.VerdictCategory>
<com.sonyericsson.hudson.plugins.gerrit.trigger.VerdictCategory>
<verdictValue>Verified</verdictValue>
<verdictDescription>Verified</verdictDescription>
</com.sonyericsson.hudson.plugins.gerrit.trigger.VerdictCategory>
</categories>
<replicationConfig>
<enableReplication>false</enableReplication>
<slaves class="linked-list"/>
<enableSlaveSelectionInJobs>false</enableSlaveSelectionInJobs>
</replicationConfig>
<watchdogTimeoutMinutes>0</watchdogTimeoutMinutes>
<watchTimeExceptionData>
<daysOfWeek/>
<timesOfDay class="linked-list"/>
</watchTimeExceptionData>
<notificationLevel>ALL</notificationLevel>
</config>
</com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer>
</servers>
<pluginConfig>
<numberOfReceivingWorkerThreads>3</numberOfReceivingWorkerThreads>
<numberOfSendingWorkerThreads>1</numberOfSendingWorkerThreads>
<replicationCacheExpirationInMinutes>360</replicationCacheExpirationInMinutes>
</pluginConfig>
</com.sonyericsson.hudson.plugins.gerrit.trigger.PluginImpl>
CONFIG
cat << CONFIG >> /var/lib/jenkins/hudson.plugins.git.GitTool.xml
<?xml version='1.0' encoding='UTF-8'?>
<hudson.plugins.git.GitTool_-DescriptorImpl plugin="git-client@1.16.1">
<installations class="hudson.plugins.git.GitTool-array">
<hudson.plugins.git.GitTool>
<name>Default</name>
<home>git</home>
<properties/>
</hudson.plugins.git.GitTool>
</installations>
</hudson.plugins.git.GitTool_-DescriptorImpl>
CONFIG
# Restart jenkins
service jenkins restart
# Grab jenkins key from gerrit

View File

@ -0,0 +1,54 @@
#!/bin/bash
OPENLDAP_IP="$1"
DOMAIN="$2"
NAME="`echo "$DOMAIN" | cut -d. -f1`"
TLD="`echo "$DOMAIN" | cut -d. -f2`"
cat << CONFIG >> /var/lib/jenkins/config.xml
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>1.0</version>
<numExecutors>2</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy\$Unsecured"/>
<securityRealm class="hudson.security.LDAPSecurityRealm" plugin="ldap@1.6">
<server>ldap://${OPENLDAP_IP}</server>
<rootDN>dc=${NAME},dc=${TLD}</rootDN>
<inhibitInferRootDN>false</inhibitInferRootDN>
<userSearchBase></userSearchBase>
<userSearch>uid={0}</userSearch>
<managerDN>cn=admin,dc=${NAME},dc=${TLD}</managerDN>
<managerPassword>b3BlbnN0YWNr</managerPassword>
<disableMailAddressResolver>false</disableMailAddressResolver>
</securityRealm>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy\$DefaultProjectNamingStrategy"/>
<workspaceDir>\${JENKINS_HOME}/workspace/\${ITEM_FULLNAME}</workspaceDir>
<buildsDir>\${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View\$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>All</primaryView>
<slaveAgentPort>0</slaveAgentPort>
<label></label>
<nodeProperties/>
<globalNodeProperties/>
</hudson>
CONFIG
service jenkins restart

View File

@ -0,0 +1,6 @@
cd ~/jenkins-job-builder
jenkins-jobs test -o output tests/yamlparser/fixtures/templates002.yaml
cat etc/jenkins_jobs.ini
ping -c 5 `grep 'url' etc/jenkins_jobs.ini | awk '{split($0,a,"/"); split(a[3],a,":"); print a[1]}'`
jenkins-jobs --conf etc/jenkins_jobs.ini update tests/yamlparser/fixtures/templates002.yaml

View File

@ -0,0 +1,20 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
# Install prerequisites
wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
apt-get update
# Jenkins
apt-get -y install jenkins
# Open firewall for jenkins
iptables -I INPUT 1 -p tcp -m tcp --dport 8080 -j ACCEPT -m comment --comment "by Murano, Jenkins"
service jenkins restart
# Create an ssh-key that can be used between Gerrit and Jenkins
sudo -u jenkins ssh-keygen -t rsa -N "" -f /var/lib/jenkins/.ssh/jenkins-id_rsa
chmod 400 /var/lib/jenkins/.ssh/jenkins-id_rsa
chmod 600 /var/lib/jenkins/.ssh/jenkins-id_rsa.pub

View File

@ -0,0 +1,8 @@
cd ~
git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
cd jenkins-job-builder
sudo apt-get install python-tox --assume-yes
tox -e venv -- sudo python setup.py install
tox -e venv -- sudo pip install -r requirements.txt

View File

@ -0,0 +1,3 @@
#!/bin/bash
echo "Ok"

View File

@ -0,0 +1,91 @@
Version: 2
Application:
?:
type: io.murano.apps.Jenkins
name: $.appConfiguration.name
ldap: $.appConfiguration.OpenLDAP
gerrit: $.appConfiguration.GerritServer
instance:
?:
type: io.murano.resources.LinuxMuranoInstance
name: generateHostname($.instanceConfiguration.unitNamingPattern, 1)
flavor: $.instanceConfiguration.flavor
image: $.instanceConfiguration.osImage
keyname: $.instanceConfiguration.keyPair
availabilityZone: $.instanceConfiguration.availabilityZone
assignFloatingIp: $.appConfiguration.assignFloatingIP
Forms:
- appConfiguration:
fields:
- name: name
type: string
label: Application Name
initial: Jenkins
description: >-
Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and
underline are allowed
- name: assignFloatingIP
type: boolean
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: true
required: false
- name: OpenLDAP
type: io.murano.apps.OpenLDAP
required: false
description: >-
Specify OpenLDAP domain for authentication
- name: GerritServer
type: io.murano.apps.Gerrit
required: false
description: >-
Specify Gerrit server
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
description: Specify some instance parameters on which the application would be created
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that application performance
depends on this parameter.
initial: m1.tiny
required: false
- name: osImage
type: image
imageType: linux
label: Instance image
description: >-
Select a valid image for the application. Image should already be prepared and
registered in glance.
- name: keyPair
type: keypair
label: Key Pair
description: >-
Select a Key Pair to control access to instances. You can login to
instances using this KeyPair after the deployment of application.
required: false
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where the application would be installed.
required: false
- name: unitNamingPattern
type: string
label: Instance Naming Pattern
required: false
maxLength: 200
regexpValidator: '^[-_\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
description: >-
Specify a string, that will be used in instance hostname.
Just A-Z, a-z, 0-9, dash and underline are allowed.

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -0,0 +1,12 @@
Format: 1.0
Type: Application
FullName: io.murano.apps.Jenkins
Name: Jenkins
Description: |
Jenkins is an open source continuous integration tool written in Java.
Author: 'Mirantis, Inc'
Tags: [Server, Java, CI, Jenkins]
Classes:
io.murano.apps.Jenkins: Jenkins.yaml
UI: ui.yaml
Logo: logo.png

View File

@ -0,0 +1,90 @@
Namespaces:
=: io.murano.apps
std: io.murano
res: io.murano.resources
sys: io.murano.system
Name: OpenLDAP
Extends: std:Application
Properties:
instance:
Contract: $.class(res:Instance).notNull()
name:
Contract: $.string().notNull()
domain:
Contract: $.string()
ldapUser:
Contract: $.string()
ldapPass:
Contract: $.string()
Methods:
initialize:
Body:
- $._environment: $.find(std:Environment).require()
deploy:
Body:
- If: not $.getAttr(deployed, false)
Then:
- $securityGroupIngress:
- ToPort: 389
FromPort: 389
IpProtocol: tcp
External: true
- ToPort: 636
FromPort: 636
IpProtocol: tcp
External: true
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
- $._environment.reporter.report($this, 'Creating VM for OpenLDAP')
- $.instance.deploy()
- $resources: new(sys:Resources)
- $template: $resources.yaml('DeployOpenLDAP.template')
- $._environment.reporter.report($this, 'OpenLDAP deploying')
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, format('OpenLDAP is available at {0}', $.instance.floatingIpAddress))
- If: $.domain != '' and $.domain != null
Then:
- $.configureOpenLDAPDomain()
- If: $.ldapUser != '' and $.ldapUser != null
Then:
- $.configureOpenLDAPUser($.domain, $.ldapUser, $.ldapPass)
- $.setAttr(deployed, true)
- $._environment.reporter.report($this, 'OpenLDAP is deployed!')
configureOpenLDAPDomain:
Body:
- If: not $.getAttr(domainConfigured, false)
Then:
- $resources: new(sys:Resources)
- $template: $resources.yaml('ConfigureOpenLDAPDomain.template').bind(dict(domain => $.domain))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, 'OpenLDAP domain is configured')
- $.setAttr(domainConfigured, true)
configureOpenLDAPUser:
Arguments:
- domain:
Contract: $.string().notNull()
- ldapUser:
Contract: $.string().notNull()
- ldapPass:
Contract: $.string().notNull()
Body:
- $.configureOpenLDAPDomain()
- $resources: new(sys:Resources)
- $template: $resources.yaml('ConfigureOpenLDAPUser.template').bind(dict(
domain => $domain,
ldapUser => $ldapUser,
ldapPass => $ldapPass
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, 'OpenLDAP user {0} is added'.format($ldapUser))
destroy:
Body:
- $.reportDestroyed()
- $.setAttr(deployed, false)

View File

@ -0,0 +1,19 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Configure OpenLDAP
Parameters:
domain: $domain
Body: |
return configure('{0}'.format(args.domain)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: configureOpenLDAPDomain.sh
Files: []
Options:
captureStdout: true
captureStderr: true

View File

@ -0,0 +1,21 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Configure OpenLDAP
Parameters:
domain: $domain
ldapUser: $ldapUser
ldapPass: $ldapPass
Body: |
return configure('{0} {1} {2}'.format(args.domain, args.ldapUser, args.ldapPass)).stdout
Scripts:
configure:
Type: Application
Version: 1.0.0
EntryPoint: configureOpenLDAPUser.sh
Files: []
Options:
captureStdout: true
captureStderr: true

View File

@ -0,0 +1,19 @@
FormatVersion: 2.0.0
Version: 1.0.0
Name: Deploy OpenLDAP
Parameters:
appName: $appName
Body: |
return deploy(args.appName).stdout
Scripts:
deploy:
Type: Application
Version: 1.0.0
EntryPoint: deployOpenLDAP.sh
Files: []
Options:
captureStdout: true
captureStderr: true

View File

@ -0,0 +1,13 @@
#!/bin/bash
DOMAIN="$1"
echo "slapd slapd/no_configuration boolean false" | debconf-set-selections
echo "slapd slapd/domain string ${DOMAIN}" | debconf-set-selections
echo "slapd shared/organization string '${DOMAIN}'" | debconf-set-selections
echo "slapd slapd/password1 password openstack" | debconf-set-selections
echo "slapd slapd/password2 password openstack" | debconf-set-selections
echo "slapd slapd/backend select HDB" | debconf-set-selections
echo "slapd slapd/purge_database boolean true" | debconf-set-selections
echo "slapd slapd/allow_ldap_v2 boolean false" | debconf-set-selections
echo "slapd slapd/move_old_database boolean true" | debconf-set-selections
dpkg-reconfigure -f noninteractive slapd

View File

@ -0,0 +1,38 @@
#!/bin/bash
DOMAIN="$1"
USERNAME="$2"
PASSWORD="$3"
NAME="`echo "$DOMAIN" | cut -d. -f1`"
TLD="`echo "$DOMAIN" | cut -d. -f2`"
# Create group.ldif and user.ldif
cat << GROUP > /tmp/group.ldif
dn: ou=users,dc=${NAME},dc=${TLD}
objectClass: top
objectClass: organizationalUnit
GROUP
cat << USER > /tmp/user.ldif
dn: uid=${USERNAME},ou=users,dc=${NAME},dc=${TLD}
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: ${USERNAME}
uid: ${USERNAME}
uidNumber: 1001
gidNumber: 1001
homeDirectory: /home/${USERNAME}
loginShell: /bin/bash
gecos: ${USERNAME}@${DOMAIN}
userPassword: {crypt}x
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
USER
ldapadd -x -w openstack -D "cn=admin,dc=${NAME},dc=${TLD}" -f /tmp/group.ldif
ldapadd -x -w openstack -D "cn=admin,dc=${NAME},dc=${TLD}" -f /tmp/user.ldif
ldappasswd -s ${PASSWORD} -D "cn=admin,dc=${NAME},dc=${TLD}" -w openstack -x uid=${USERNAME},ou=users,dc=${NAME},dc=${TLD}

View File

@ -0,0 +1,12 @@
#!/bin/bash
apt-get update
apt-get install -y debconf
echo "slapd slapd/root_password password openstack" | debconf-set-selections
echo "slapd slapd/root_password_again password openstack" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils
# Open firewall for ldap/ldaps
iptables -I INPUT 1 -p tcp -m tcp --dport 389 -j ACCEPT -m comment --comment "by murano, OpenLDAP server access on port 389"
iptables -I INPUT 1 -p tcp -m tcp --dport 636 -j ACCEPT -m comment --comment "by murano, OpenLDAP server access on port 636"

View File

@ -0,0 +1,104 @@
Version: 2
Application:
?:
type: io.murano.apps.OpenLDAP
name: $.appConfiguration.name
domain: $.appConfiguration.domain
ldapUser: $.appConfiguration.ldapUser
ldapPass: $.appConfiguration.ldapPass
instance:
?:
type: io.murano.resources.LinuxMuranoInstance
name: generateHostname($.instanceConfiguration.unitNamingPattern, 1)
flavor: $.instanceConfiguration.flavor
image: $.instanceConfiguration.osImage
keyname: $.instanceConfiguration.keyPair
availabilityZone: $.instanceConfiguration.availabilityZone
assignFloatingIp: $.appConfiguration.assignFloatingIP
Forms:
- appConfiguration:
fields:
- name: name
type: string
label: Application Name
initial: OpenLDAP
description: >-
Enter a desired name for the application. Just A-Z, a-z, 0-9, dash
and underline are allowed
- name: domain
type: string
label: Domain
initial: domain.tld
required: false
descriptionTitle: Domain
description: >-
Please, provide domain for the OpenLDAP instance
- name: ldapUser
type: string
label: Username
required: false
descriptionTitle: LDAP User
description: >-
Please, provide username
- name: ldapPass
type: password
label: Password
required: false
descriptionTitle: LDAP Password
description: >-
Please, provide password
- name: assignFloatingIP
type: boolean
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: true
required: false
- instanceConfiguration:
fields:
- name: title
type: string
required: false
hidden: true
description: Specify some instance parameters on which the application would be created
- name: flavor
type: flavor
label: Instance flavor
description: >-
Select registered in Openstack flavor. Consider that application performance
depends on this parameter.
initial: m1.tiny
required: false
- name: osImage
type: image
imageType: linux
label: Instance image
description: >-
Select a valid image for the application. Image should already be prepared and
registered in glance.
- name: keyPair
type: keypair
label: Key Pair
description: >-
Select a Key Pair to control access to instances. You can login to
instances using this KeyPair after the deployment of application.
required: false
- name: availabilityZone
type: azone
label: Availability zone
description: Select availability zone where the application would be installed.
required: false
- name: unitNamingPattern
type: string
label: Instance Naming Pattern
required: false
maxLength: 200
regexpValidator: '^[-_\w]+$'
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
helpText: Just letters, numbers, underscores and hyphens are allowed.
description: >-
Specify a string, that will be used in instance hostname.
Just A-Z, a-z, 0-9, dash and underline are allowed.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -0,0 +1,12 @@
Format: 1.0
Type: Application
FullName: io.murano.apps.OpenLDAP
Name: OpenLDAP
Description: |
OpenLDAP is an open source implementation of the Lightweight Directory Access Protocol.
Author: 'Mirantis, Inc'
Tags: [Server, LDAP]
Classes:
io.murano.apps.OpenLDAP: OpenLDAP.yaml
UI: ui.yaml
Logo: logo.png