
After patch Ia2498bdb0f7c310ec3d2c2f11f5d3fc08c8b352c there is possible to run check for yaml and shell syntax. This patch is oriented to fix some similar Warnings reported in yaml syntax check for CI/CD apps, like "(indentation)". Change-Id: Ie2d854e6feef6362ea07d6132e71072dae49b5d7
230 lines
8.4 KiB
YAML
230 lines
8.4 KiB
YAML
Namespaces:
|
|
=: org.openstack.ci_cd_pipeline_murano_app
|
|
std: io.murano
|
|
sys: io.murano.system
|
|
ci_cd_pipeline_murano_app: org.openstack.ci_cd_pipeline_murano_app
|
|
puppet: org.openstack.ci_cd_pipeline_murano_app.puppet
|
|
conf: io.murano.configuration
|
|
|
|
Name: Gerrit
|
|
|
|
Extends: std:Application
|
|
|
|
Properties:
|
|
instance:
|
|
Contract: $.class(puppet:PuppetInstance).notNull()
|
|
name:
|
|
Contract: $.string().notNull()
|
|
warUrl:
|
|
Contract: $.string()
|
|
Default: 'http://tarballs.openstack.org/ci/test/gerrit-v2.11.9.3.eb6e48d.war'
|
|
ldap:
|
|
Contract: $.class(ci_cd_pipeline_murano_app:OpenLDAP)
|
|
userSSH:
|
|
Contract: $.string()
|
|
systemConfigRepo:
|
|
Contract: $.class(puppet:SystemConfig)
|
|
|
|
Methods:
|
|
initialize:
|
|
Body:
|
|
- $._environment: $.find(std:Environment).require()
|
|
|
|
deploy:
|
|
Body:
|
|
- super($this, $.deploy())
|
|
- If: $.getAttr(deployed, false)
|
|
Then:
|
|
Return:
|
|
|
|
- $securityGroupIngress:
|
|
- ToPort: 80
|
|
FromPort: 80
|
|
IpProtocol: tcp
|
|
External: true
|
|
- ToPort: 443
|
|
FromPort: 443
|
|
IpProtocol: tcp
|
|
External: true
|
|
- ToPort: 8081
|
|
FromPort: 8081
|
|
IpProtocol: tcp
|
|
External: true
|
|
- ToPort: 29418
|
|
FromPort: 29418
|
|
IpProtocol: tcp
|
|
External: true
|
|
|
|
- $._environment.securityGroupManager.addGroupIngress($securityGroupIngress)
|
|
- $._environment.reporter.report($this, 'Creating VM for Gerrit "{0}"'.format($.instance.name))
|
|
- $.instance.deploy()
|
|
- $._environment.reporter.report($this, 'Gerrit VM "{0}" with id {1} created'.format($.instance.name, $.instance.openstackId))
|
|
|
|
- $._environment.reporter.report($this, 'Installing puppet modules...')
|
|
|
|
# initialize System Config
|
|
- If: $.systemConfigRepo = null
|
|
Then:
|
|
- $this.systemConfig: new(puppet:SystemConfig)
|
|
Else:
|
|
- $this.systemConfig: $.systemConfigRepo
|
|
- $this.systemConfig.installOnTheNode($this.instance)
|
|
|
|
- If: $.ldap != null
|
|
Then:
|
|
- $._environment.reporter.report($this, 'Waiting while LDAP is being deployed...')
|
|
- $.ldap.deploy()
|
|
|
|
- $.createConfiguration()
|
|
|
|
- $._deployGerrit()
|
|
- $._environment.reporter.report($this, 'Switching Gerrit to a local project-config')
|
|
- $._switchProjectConfig()
|
|
- If: $.ldap != null and not $.userSSH in [null, ''] and not $.ldap.ldapUser in [null, '']
|
|
Then:
|
|
- $._environment.reporter.report($this, "Adding user's SSH public key to Gerrit.")
|
|
|
|
- $.createAccount('', $.ldap.ldapUser, $.ldap.ldapEmail, $.userSSH, $.ldap.ldapUser)
|
|
|
|
- $._environment.reporter.report($this, 'Gerrit is deployed.')
|
|
- $linux: new(conf:Linux)
|
|
- $gerritHost: $linux.runCommand($.instance.agent, 'hostname -f').stdout
|
|
- If: $.instance.assignFloatingIp
|
|
Then:
|
|
- $gerritIP: $.instance.floatingIpAddress
|
|
Else:
|
|
- $gerritIP: $.instance.ipAddresses[0]
|
|
- $._environment.reporter.report($this, format('Gerrit service is launched on host {0} accessing by IP {1}.', $gerritHost, $gerritIP))
|
|
- $._environment.reporter.report($this, format('Gerrit is available at http://{0}:80 or http://{0}:8081', $gerritIP))
|
|
- $.setAttr(deployed, true)
|
|
|
|
_deployGerrit:
|
|
Body:
|
|
- $._environment.reporter.report($this, 'Deploying Gerrit...')
|
|
- $resources: new(sys:Resources)
|
|
- $template: $resources.yaml('DeployGerrit.template')
|
|
- $.instance.agent.call($template, $resources)
|
|
|
|
#
|
|
# Project-config local repo
|
|
#
|
|
getProjectConfigRepo:
|
|
Body:
|
|
- Return: format('https://{0}/open-paas/project-config', $this.instance.ipAddresses[0])
|
|
|
|
#
|
|
# Switch to newly created project-config repo
|
|
#
|
|
_switchProjectConfig:
|
|
Body:
|
|
- $.instance.putHieraData({'project_config_repo' => $.getProjectConfigRepo()})
|
|
|
|
_createLdapConfiguration:
|
|
Body:
|
|
- $ldapInstance: $.ldap.instance
|
|
- If: $ldapInstance.assignFloatingIp
|
|
Then:
|
|
- $ldapHost: $ldapInstance.floatingIpAddress
|
|
Else:
|
|
- $ldapHost: $ldapInstance.ipAddresses[0]
|
|
|
|
- $data:
|
|
ldap_ip: $ldapHost
|
|
ldap_domain: $.ldap.domain
|
|
ldap_root_user: $.ldap.ldapRootUser
|
|
ldap_root_password: $.ldap.ldapRootPass
|
|
ldap_user: $.ldap.ldapUser
|
|
ldap_password: $.ldap.ldapPass
|
|
|
|
- $this.instance.putHieraData($data)
|
|
|
|
createConfiguration:
|
|
Body:
|
|
- If: $this.ldap != null
|
|
Then:
|
|
- $._createLdapConfiguration()
|
|
|
|
- $data:
|
|
gerrit_war_url: $this.warUrl
|
|
gerrit_github_token: ''
|
|
github_project_username: 'mirademo'
|
|
gerrit_mysql_host: 'localhost'
|
|
gerritbot_password: 'P@ssw0rd'
|
|
gerrit_db_user: 'gerrit2'
|
|
gerrit_db_password: '12345'
|
|
gerrit_db_root_password: 'P@ssw0rd'
|
|
gerrit_acls_dir: '/etc/project-config/gerrit/acls'
|
|
gerrit_notify_impact_file: '/etc/project-config/gerrit/notify_impact.yaml'
|
|
jeepyb_project_file: '/etc/project-config/gerrit/projects.yaml'
|
|
project_config_config_dir: '/etc/project-config/'
|
|
github_project_password: 'dummy content. to be done'
|
|
gerrit_email_private_key: 'dummy content. to be done'
|
|
gerrit_rest_token_private_key: 'dummy content. to be done'
|
|
welcome_message_gerrit_ssh_private_key: 'dummy content. to be done'
|
|
welcome_message_gerrit_ssh_public_key: 'dummy content. to be done'
|
|
ssh_replication_rsa_key_contents: 'dummy content. to be done'
|
|
gerrit_replication_ssh_rsa_pubkey_contents: 'dummy content. to be done'
|
|
gerrit_lp_consumer_key: 'dummy content. to be done'
|
|
gerrit_lp_access_token: 'dummy content. to be done'
|
|
gerrit_lp_access_secret: 'dummy content. to be done'
|
|
gerrit_contactstore_appsec: 'dummy content. to be done'
|
|
gerrit_contactstore_pubkey: 'dummy content. to be done'
|
|
swift_store_user: 'dummy content. to be done'
|
|
swift_store_key: 'dummy content. to be done'
|
|
# This fields autogenerated on vm
|
|
# TODO: These values should be stored in Murano too
|
|
# gerritbot_ssh_rsa_key_contents: 'dummy content. the value should be autogenerated'
|
|
# gerritbot_ssh_rsa_pubkey_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssh_dsa_key_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssh_dsa_pubkey_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssh_rsa_key_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssh_rsa_pubkey_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssh_project_rsa_key_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssh_project_rsa_pubkey_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssl_cert_file_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssl_key_file_contents: 'dummy content. the value should be autogenerated'
|
|
# gerrit_ssl_chain_file_contents: 'dummy content. the value should be autogenerated'
|
|
|
|
- $this.instance.putHieraData($data)
|
|
- $this.instance.syncHieraData()
|
|
|
|
|
|
#NOTE: this method doesn't work without ldap
|
|
createAccount:
|
|
Arguments:
|
|
- group:
|
|
Contract: $.string()
|
|
- fullName:
|
|
Contract: $.string().notNull()
|
|
- email:
|
|
Contract: $.string().notNull()
|
|
- sshKey:
|
|
Contract: $.string().notNull()
|
|
- name:
|
|
Contract: $.string().notNull()
|
|
Body:
|
|
- $resources: new(sys:Resources)
|
|
- $template: $resources.yaml('CreateAccount.template').bind(dict(
|
|
gerritUser => $.ldap.ldapRootUser,
|
|
group => $group,
|
|
fullName => $fullName,
|
|
email => $email,
|
|
sshKey => $sshKey,
|
|
name => $name))
|
|
- $.instance.agent.call($template, $resources)
|
|
|
|
createLabels:
|
|
Body:
|
|
- $._environment.reporter.report($this, 'Creating label "Verified" in Gerrit...')
|
|
- $linux: new(conf:Linux)
|
|
- $resource: new(sys:Resources)
|
|
|
|
- $script: $resource.string('scripts/create_gerrit_labels.sh')
|
|
- $linux.runCommand($.instance.agent, $script)
|
|
- $._environment.reporter.report($this, 'Label "Verified" is successfully created.')
|
|
|
|
destroy:
|
|
Body:
|
|
- $.reportDestroyed()
|
|
- $.setAttr(deployed, false)
|