diff --git a/ansible/bootstrap-mongodb.yml b/ansible/bootstrap-mongodb.yml new file mode 100644 index 0000000000000000000000000000000000000000..faf1a22d5c99783f0cbf14f8404e7cb22c7a69e8 --- /dev/null +++ b/ansible/bootstrap-mongodb.yml @@ -0,0 +1,20 @@ +--- +- hosts: mongo + become: yes + gather_facts: no + vars_files: + - "{{inventory_dir}}/secrets.yml" + tasks: + - name: Template and init nodbb db + block: + - name: Templating nodebb schema + copy: + content: |- + use nodebb + db.createUser( { user: "nodebb", pwd: "{{ nodebb_admin_password }}", roles: [ { role: "readWrite", db: "nodebb" }, { role: "clusterMonitor", db: "admin" } ] } ) + dest: /tmp/nodebb.js + - name: Init nodebb db + shell: |- + mongo < /tmp/nodebb.js + tags: + - nodebb diff --git a/pipelines/nodebb/Jenkinsfile b/pipelines/nodebb/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..c3ce3d9f1995b6b0c17f1240a7396bde6ef71773 --- /dev/null +++ b/pipelines/nodebb/Jenkinsfile @@ -0,0 +1,52 @@ + +@Library('deploy-conf') _ +node() { + try { + String ANSI_GREEN = "\u001B[32m" + String ANSI_NORMAL = "\u001B[0m" + String ANSI_BOLD = "\u001B[1m" + String ANSI_RED = "\u001B[31m" + String ANSI_YELLOW = "\u001B[33m" + + stage('checkout public repo') { + folder = new File("$WORKSPACE/.git") + if (folder.exists()) + { + println "Found .git folder. Clearing it.." + sh'git clean -fxd' + } + checkout scm + } + + ansiColor('xterm') { + stage('deploy'){ + values = [:] + envDir = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-3].trim() + module = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-2].trim() + jobName = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-1].trim() + currentWs = sh(returnStdout: true, script: 'pwd').trim() + ansiblePlaybook = "${currentWs}/ansible/bootstrap-mongodb.yml" + ansibleExtraArgs = "--vault-password-file /var/lib/jenkins/secrets/vault-pass --tags ${params.tag_name}" + values.put('currentWs', currentWs) + values.put('env', envDir) + values.put('module', module) + values.put('jobName', jobName) + values.put('ansiblePlaybook', ansiblePlaybook) + values.put('ansibleExtraArgs', ansibleExtraArgs) + println values + ansible_playbook_run(values) + currentBuild.result = 'SUCCESS' + currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}" + } + } + summary() + } + catch (err) { + currentBuild.result = 'FAILURE' + throw err + } + finally { + slack_notify(currentBuild.result) + email_notify() + } +}