diff --git a/murano-apps/Jenkins/package/Classes/Jenkins.yaml b/murano-apps/Jenkins/package/Classes/Jenkins.yaml index 4fa34d9..a854f93 100644 --- a/murano-apps/Jenkins/package/Classes/Jenkins.yaml +++ b/murano-apps/Jenkins/package/Classes/Jenkins.yaml @@ -1,8 +1,10 @@ Namespaces: - =: io.murano.apps + =: io.murano.opaas std: io.murano res: io.murano.resources sys: io.murano.system + opaas: io.murano.opaas + puppet: io.murano.opaas.puppet Name: Jenkins @@ -11,12 +13,8 @@ Extends: std:Application Properties: name: Contract: $.string().notNull() - ldap: - Contract: $.class(OpenLDAP) - gerrit: - Contract: $.class(Gerrit) instance: - Contract: $.class(res:Instance).notNull() + Contract: $.class(puppet:PuppetInstance).notNull() Methods: initialize: @@ -25,39 +23,29 @@ Methods: deploy: Body: + - $.super($.deploy()) - If: not $.getAttr(deployed, false) Then: - - $._environment.reporter.report($this, 'Creating VM for Jenkins') + - $._environment.reporter.report($this, 'Creating security group for Jenkins') - $securityGroupIngress: - ToPort: 8080 FromPort: 8080 IpProtocol: tcp External: true - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) + + - $._environment.reporter.report($this, 'Creating VM for Jenkins {0}'.format($.instance.openstackId)) - $.instance.deploy() + - $._environment.reporter.report($this, 'Jenkins VM {0} created'.format($.instance.openstackId)) + + - $this.projectConfig: new(puppet:ProjectConfig) + - $this.projectConfig.installOnTheNode($this.instance) + - $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 @@ -66,88 +54,6 @@ Methods: - $._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: diff --git a/murano-apps/Jenkins/package/Resources/ConfigureJJB.template b/murano-apps/Jenkins/package/Resources/ConfigureJJB.template deleted file mode 100644 index e5a375b..0000000 --- a/murano-apps/Jenkins/package/Resources/ConfigureJJB.template +++ /dev/null @@ -1,22 +0,0 @@ -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 \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/ConnectGerrit.template b/murano-apps/Jenkins/package/Resources/ConnectGerrit.template deleted file mode 100644 index 3c97add..0000000 --- a/murano-apps/Jenkins/package/Resources/ConnectGerrit.template +++ /dev/null @@ -1,21 +0,0 @@ -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 diff --git a/murano-apps/Jenkins/package/Resources/ConnectLDAP.template b/murano-apps/Jenkins/package/Resources/ConnectLDAP.template deleted file mode 100644 index 0c1c525..0000000 --- a/murano-apps/Jenkins/package/Resources/ConnectLDAP.template +++ /dev/null @@ -1,21 +0,0 @@ -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 diff --git a/murano-apps/Jenkins/package/Resources/CreateTestJob.template b/murano-apps/Jenkins/package/Resources/CreateTestJob.template deleted file mode 100644 index b4297fe..0000000 --- a/murano-apps/Jenkins/package/Resources/CreateTestJob.template +++ /dev/null @@ -1,17 +0,0 @@ -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 \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/DeployJenkins.template b/murano-apps/Jenkins/package/Resources/DeployJenkins.template index 009e018..23c89a0 100644 --- a/murano-apps/Jenkins/package/Resources/DeployJenkins.template +++ b/murano-apps/Jenkins/package/Resources/DeployJenkins.template @@ -1,20 +1,17 @@ -FormatVersion: 2.0.0 +FormatVersion: 2.1.0 Version: 1.0.0 Name: Deploy Jenkins -Parameters: - appName: $appName Body: | - return deploy(args.appName).stdout + return deploy().stdout Scripts: deploy: Type: Application Version: 1.0.0 - EntryPoint: deployJenkins.sh - Files: [] + EntryPoint: deploy.sh + Files: ['site.pp'] Options: captureStdout: true captureStderr: true - verifyExitcode: false diff --git a/murano-apps/Jenkins/package/Resources/GetKey.template b/murano-apps/Jenkins/package/Resources/GetKey.template deleted file mode 100644 index 0e2fae8..0000000 --- a/murano-apps/Jenkins/package/Resources/GetKey.template +++ /dev/null @@ -1,22 +0,0 @@ -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 diff --git a/murano-apps/Jenkins/package/Resources/InstallJJB.template b/murano-apps/Jenkins/package/Resources/InstallJJB.template deleted file mode 100644 index 310065c..0000000 --- a/murano-apps/Jenkins/package/Resources/InstallJJB.template +++ /dev/null @@ -1,17 +0,0 @@ -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 \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configureJJB.sh b/murano-apps/Jenkins/package/Resources/scripts/configureJJB.sh deleted file mode 100644 index 0bfa1d6..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/configureJJB.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 - - - diff --git a/murano-apps/Jenkins/package/Resources/scripts/connectGerrit.sh b/murano-apps/Jenkins/package/Resources/scripts/connectGerrit.sh deleted file mode 100644 index 25c321e..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/connectGerrit.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -GERRIT_IP="$1" -DOMAIN="$2" - -cat << CONFIG >> /var/lib/jenkins/credentials.xml - - - - - - - - - - GLOBAL - 10055155-5c33-4318-8161-96a3ccd270a8 - - jenkins - aE53R1jYUuH1K2BgkbGqfw== - - /var/lib/jenkins/.ssh/jenkins-id_rsa - - - - - - -CONFIG - -cat << CONFIG >> /var/lib/jenkins/gerrit-trigger.xml - - - - - Gerrit - false - - ${GERRIT_IP} - 29418 - - jenkins - jenkins@${DOMAIN} - /var/lib/jenkins/.ssh/jenkins-id_rsa - aE53R1jYUuH1K2BgkbGqfw== - false - false - false - false - gerrit review <CHANGE>,<PATCHSET> --message 'Build Successful <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> - gerrit review <CHANGE>,<PATCHSET> --message 'Build Unstable <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> - gerrit review <CHANGE>,<PATCHSET> --message 'Build Failed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> - gerrit review <CHANGE>,<PATCHSET> --message 'Build Started <BUILDURL> <STARTED_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> - gerrit review <CHANGE>,<PATCHSET> --message 'No Builds Executed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> - http://${GERRIT_IP}:8080/ - 0 - 0 - 1 - 0 - -1 - 0 - 0 - -1 - 0 - 0 - true - true - 3 - 30 - - - Code-Review - Code Review - - - Verified - Verified - - - - false - - false - - 0 - - - - - ALL - - - - - 3 - 1 - 360 - - -CONFIG - -cat << CONFIG >> /var/lib/jenkins/hudson.plugins.git.GitTool.xml - - - - - Default - git - - - - -CONFIG - -# Restart jenkins -service jenkins restart - -# Grab jenkins key from gerrit diff --git a/murano-apps/Jenkins/package/Resources/scripts/connectLDAP.sh b/murano-apps/Jenkins/package/Resources/scripts/connectLDAP.sh deleted file mode 100644 index f0b98ae..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/connectLDAP.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/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 - - - - 1.0 - 2 - NORMAL - true - - - ldap://${OPENLDAP_IP} - dc=${NAME},dc=${TLD} - false - - uid={0} - cn=admin,dc=${NAME},dc=${TLD} - b3BlbnN0YWNr - false - - false - - \${JENKINS_HOME}/workspace/\${ITEM_FULLNAME} - \${ITEM_ROOTDIR}/builds - - - - - - 0 - - - - All - false - false - - - - All - 0 - - - - -CONFIG - -service jenkins restart diff --git a/murano-apps/Jenkins/package/Resources/scripts/createTestJob.sh b/murano-apps/Jenkins/package/Resources/scripts/createTestJob.sh deleted file mode 100644 index 6c723a7..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/createTestJob.sh +++ /dev/null @@ -1,6 +0,0 @@ -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 diff --git a/murano-apps/Jenkins/package/Resources/scripts/deploy.sh b/murano-apps/Jenkins/package/Resources/scripts/deploy.sh new file mode 100644 index 0000000..1edd7fd --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/deploy.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +puppet apply site.pp \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/deployJenkins.sh b/murano-apps/Jenkins/package/Resources/scripts/deployJenkins.sh deleted file mode 100644 index d21e7b9..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/deployJenkins.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/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 - diff --git a/murano-apps/Jenkins/package/Resources/scripts/installJJB.sh b/murano-apps/Jenkins/package/Resources/scripts/installJJB.sh deleted file mode 100644 index a03d04c..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/installJJB.sh +++ /dev/null @@ -1,8 +0,0 @@ -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 - diff --git a/murano-apps/Jenkins/package/Resources/scripts/noop.sh b/murano-apps/Jenkins/package/Resources/scripts/noop.sh deleted file mode 100644 index cb99fc5..0000000 --- a/murano-apps/Jenkins/package/Resources/scripts/noop.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo "Ok" diff --git a/murano-apps/Jenkins/package/Resources/scripts/site.pp b/murano-apps/Jenkins/package/Resources/scripts/site.pp new file mode 100644 index 0000000..70dc3c3 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/site.pp @@ -0,0 +1,9 @@ +node default { + class { 'openstack_project::jenkins': + jenkins_password => '', + jenkins_ssh_private_key => '', + ssl_cert_file => '/etc/ssl/certs/ssl-cert-snakeoil.pem', + ssl_key_file => '/etc/ssl/private/ssl-cert-snakeoil.key', + ssl_chain_file => '', + } +} \ No newline at end of file diff --git a/murano-apps/Jenkins/package/UI/ui.yaml b/murano-apps/Jenkins/package/UI/ui.yaml index d89b7c2..0d53fa6 100644 --- a/murano-apps/Jenkins/package/UI/ui.yaml +++ b/murano-apps/Jenkins/package/UI/ui.yaml @@ -2,13 +2,11 @@ Version: 2 Application: ?: - type: io.murano.apps.Jenkins + type: io.murano.opaas.Jenkins name: $.appConfiguration.name - ldap: $.appConfiguration.OpenLDAP - gerrit: $.appConfiguration.GerritServer instance: ?: - type: io.murano.resources.LinuxMuranoInstance + type: io.murano.opaas.puppet.PuppetInstance name: generateHostname($.instanceConfiguration.unitNamingPattern, 1) flavor: $.instanceConfiguration.flavor image: $.instanceConfiguration.osImage @@ -22,7 +20,7 @@ Forms: - name: name type: string label: Application Name - initial: Jenkins + initial: JenkinsPuppet description: >- Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and underline are allowed @@ -33,16 +31,6 @@ Forms: 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 diff --git a/murano-apps/Jenkins/package/manifest.yaml b/murano-apps/Jenkins/package/manifest.yaml index 79339a4..b087883 100644 --- a/murano-apps/Jenkins/package/manifest.yaml +++ b/murano-apps/Jenkins/package/manifest.yaml @@ -1,12 +1,12 @@ Format: 1.0 Type: Application -FullName: io.murano.apps.Jenkins +FullName: io.murano.opaas.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 + io.murano.opaas.Jenkins: Jenkins.yaml UI: ui.yaml Logo: logo.png