diff options
| author | ckonstanski <ckonstanski@pippiandcarlos.com> | 2017-10-24 18:27:27 -0600 |
|---|---|---|
| committer | ckonstanski <ckonstanski@pippiandcarlos.com> | 2017-10-24 18:27:27 -0600 |
| commit | 0493747f5d1b30008b4170b3d48080abfa224700 (patch) | |
| tree | 4ee87ddb639f30a47e95861409a1b9d71d183e07 | |
| parent | dd48453e079d5c93f7cf0af59843bd7d4180e186 (diff) | |
make it work for all 4 git branches
21 files changed, 467 insertions, 179 deletions
diff --git a/bootstrap/pillar_config.rb b/bootstrap/pillar_config.rb index 8b4abb4..9b0b1bb 100755 --- a/bootstrap/pillar_config.rb +++ b/bootstrap/pillar_config.rb @@ -2,6 +2,7 @@ require_relative 'http_client' require 'digest' +require 'getoptlong' require "json" require 'socket' require "yaml" @@ -27,7 +28,7 @@ def get_ip_address() end end -def get_jar_versions(yml) +def get_jar_versions(yml, branch) ret = Hash.new begin http_client = HttpClient.new(url: yml["jars"]["url"], @@ -35,7 +36,7 @@ def get_jar_versions(yml) password: yml["jars"]["password"]) http_client.do_http(method: :propfind) http_client.response.each_line do |line| - if line =~ /D:href.*\.jar/ + if line =~ /D:href.*#{branch}.*\.jar/ jar_name = line.chomp.split(/[<>]/)[2] jarparts = jar_name.split(/\//) name, *version_parts, junk1 = jarparts[jarparts.length - 1].split(".") @@ -72,8 +73,18 @@ def process_yaml() end def main() + branch = "" + opts = GetoptLong.new(["--branch", "-b", GetoptLong::REQUIRED_ARGUMENT]) + + opts.each do |opt, arg| + case opt + when "--branch" + branch = arg + end + end + yml = process_yaml() - puts yml.merge(get_jar_versions(yml)).to_json + puts yml.merge(get_jar_versions(yml, branch)).to_json end main() diff --git a/bootstrap/run_salt.sh b/bootstrap/run_salt.sh index 869b52b..6c973fd 100755 --- a/bootstrap/run_salt.sh +++ b/bootstrap/run_salt.sh @@ -1,4 +1,5 @@ #!/bin/bash -salt '*' state.highstate pillar="$($(dirname ${0})/pillar_config.rb)" +branch="${1}" +salt '*' state.highstate pillar="$($(dirname ${0})/pillar_config.rb ${branch})" exit 0 diff --git a/build-docker-containers.sh b/build-docker-containers.sh index 11a8d79..38fbb24 100755 --- a/build-docker-containers.sh +++ b/build-docker-containers.sh @@ -1,5 +1,7 @@ #!/bin/bash +artifact="${1}" +branch="${2}" buildroot="$(pwd)" # clean docker containers @@ -29,10 +31,10 @@ sudo ln -s ${buildroot}/salt /srv/salt cp ${HOME}/config.yaml /srv/bootstrap/ # run salt to create build scripts -sudo /srv/bootstrap/run_salt.sh +sudo /srv/bootstrap/run_salt.sh --branch=${branch} # build new docker containers -sudo /root/openbook_build/ci/build.sh ${1} +sudo /root/openbook_build/ci/build.sh ${artifact} # refresh openbook-v4-installer repo (ansible playbook) pushd ${HOME} diff --git a/jjb/yaml/deploy-dev-env.yaml b/jjb/yaml/deploy-branch.yaml index 8172369..a8a3746 100644 --- a/jjb/yaml/deploy-dev-env.yaml +++ b/jjb/yaml/deploy-branch.yaml @@ -1,6 +1,16 @@ --- -- job: - name: deploy-dev-env +- project: + name: "deploy-branch" + branch: + - "unstable" + - "develop" + - "stage" + - "master" + jobs: + - "deploy-branch-{branch}" + +- job-template: + name: "deploy-branch-{branch}" project-type: freestyle node: openbook_v4 properties: @@ -17,12 +27,12 @@ triggers: - reverse: jobs: - - "admin-api-server-pipeline" - - "admin-web-ui-pipeline" - - "customer-api-server-pipeline" - - "customer-web-ui-pipeline" - - "job-scheduler-server-pipeline" - - "workflow-server-pipeline" + - "admin-api-server-{branch}-pipeline" + - "admin-web-ui-{branch}-pipeline" + - "customer-api-server-{branch}-pipeline" + - "customer-web-ui-{branch}-pipeline" + - "job-scheduler-server-{branch}-pipeline" + - "workflow-server-{branch}-pipeline" scm: - git: url: git@github.com:Talligent/openbook-v4-installer.git @@ -30,4 +40,4 @@ - master builders: - shell: | - ./deploy-dev-env.sh + ./deploy-branch.sh {branch} diff --git a/jjb/yaml/openbook-all-pipeline.yaml b/jjb/yaml/openbook-all-pipeline.yaml index 1c5fbca..42ed780 100644 --- a/jjb/yaml/openbook-all-pipeline.yaml +++ b/jjb/yaml/openbook-all-pipeline.yaml @@ -1,60 +1,70 @@ --- -- job: - name: openbook-all-pipeline +- project: + name: "openbook-all-pipeline" + branch: + - "unstable" + - "develop" + - "stage" + - "master" + jobs: + - "openbook-all-{branch}-pipeline" + +- job-template: + name: "openbook-all-{branch}-pipeline" project-type: pipeline dsl: | - pipeline { - agent { - node { + pipeline {{ + agent {{ + node {{ label "master" - } - } - stages { - stage("checkout") { - agent { - node { + }} + }} + stages {{ + stage("checkout") {{ + agent {{ + node {{ label "openbook_v4" customWorkspace "workspace/openbook-all" - } - } - steps { - git(poll: false, branch: "unstable", url: "git@github.com:Talligent/openbook-core.git") - } - } - stage("database") { - steps { + }} + }} + steps {{ + git(poll: false, branch: "{branch}", url: "git@github.com:Talligent/openbook-core.git") + }} + }} + stage("database") {{ + steps {{ build(job: "openbook-database") - } - } - stage("admin-api-server") { - steps { - build(job: "admin-api-server-pipeline") - } - } - stage("customer-api-server") { - steps { - build(job: "customer-api-server-pipeline") - } - } - stage("admin-web-ui") { - steps { - build(job: "admin-web-ui-pipeline") - } - } - stage("customer-web-ui") { - steps { - build(job: "customer-web-ui-pipeline") - } - } - stage("job-scheduler-server") { - steps { - build(job: "job-scheduler-server-pipeline") - } - } - stage("workflow-server") { - steps { - build(job: "workflow-server-pipeline") - } - } - } - } + }} + }} + stage("admin-api-server") {{ + steps {{ + build(job: "admin-api-server-{branch}-pipeline") + }} + }} + stage("customer-api-server") {{ + steps {{ + build(job: "customer-api-server-{branch}-pipeline") + }} + }} + stage("admin-web-ui") {{ + steps {{ + build(job: "admin-web-ui-{branch}-pipeline") + }} + }} + stage("customer-web-ui") {{ + steps {{ + build(job: "customer-web-ui-{branch}-pipeline") + }} + }} + stage("job-scheduler-server") {{ + steps {{ + build(job: "job-scheduler-server-{branch}-pipeline") + }} + }} + stage("workflow-server") {{ + steps {{ + build(job: "workflow-server-{branch}-pipeline") + }} + }} + }} + }} diff --git a/jjb/yaml/openbook-core-pipeline.yaml b/jjb/yaml/openbook-core-pipeline.yaml index 7a4da87..d92b605 100644 --- a/jjb/yaml/openbook-core-pipeline.yaml +++ b/jjb/yaml/openbook-core-pipeline.yaml @@ -1,45 +1,55 @@ --- -- job: - name: openbook-core-pipeline +- project: + name: "openbook-core-pipeline" + branch: + - "unstable" + - "develop" + - "stage" + - "master" + jobs: + - "openbook-core-{branch}-pipeline" + +- job-template: + name: "openbook-core-{branch}-pipeline" project-type: pipeline dsl: | - pipeline { - agent { - node { + pipeline {{ + agent {{ + node {{ label "master" - } - } - stages { - stage("checkout") { - agent { - node { + }} + }} + stages {{ + stage("checkout") {{ + agent {{ + node {{ label "openbook_v4" customWorkspace "workspace/openbook-core" - } - } - steps { - git(branch: "unstable", url: "git@github.com:Talligent/openbook-core.git") - } - } - stage("admin-api-server") { - steps { - build(job: "admin-api-server-pipeline") - } - } - stage("customer-api-server") { - steps { - build(job: "customer-api-server-pipeline") - } - } - stage("job-scheduler-server") { - steps { - build(job: "job-scheduler-server-pipeline") - } - } - stage("workflow-server") { - steps { - build(job: "workflow-server-pipeline") - } - } - } - } + }} + }} + steps {{ + git(branch: "{branch}", url: "git@github.com:Talligent/openbook-core.git") + }} + }} + stage("admin-api-server") {{ + steps {{ + build(job: "admin-api-server-{branch}-pipeline") + }} + }} + stage("customer-api-server") {{ + steps {{ + build(job: "customer-api-server-{branch}-pipeline") + }} + }} + stage("job-scheduler-server") {{ + steps {{ + build(job: "job-scheduler-server-{branch}-pipeline") + }} + }} + stage("workflow-server") {{ + steps {{ + build(job: "workflow-server-{branch}-pipeline") + }} + }} + }} + }} diff --git a/jjb/yaml/openbook-pipeline.yaml b/jjb/yaml/openbook-pipeline.yaml index 5fcfbbe..c379af5 100644 --- a/jjb/yaml/openbook-pipeline.yaml +++ b/jjb/yaml/openbook-pipeline.yaml @@ -1,18 +1,106 @@ --- - project: name: "openbook-pipeline" - artifact: - - "admin-api-server" - - "admin-web-ui" - - "customer-api-server" - - "customer-web-ui" - - "job-scheduler-server" - - "workflow-server" jobs: - - "{artifact}-pipeline" + - "{artifact}-{branch}-pipeline": + artifact: "admin-api-server" + branch: "unstable" + tag: "4.1" + - "{artifact}-{branch}-pipeline": + artifact: "admin-api-server" + branch: "develop" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "admin-api-server" + branch: "stage" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "admin-api-server" + branch: "master" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "admin-web-ui" + branch: "unstable" + tag: "4.1" + - "{artifact}-{branch}-pipeline": + artifact: "admin-web-ui" + branch: "develop" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "admin-web-ui" + branch: "stage" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "admin-web-ui" + branch: "master" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "customer-api-server" + branch: "unstable" + tag: "4.1" + - "{artifact}-{branch}-pipeline": + artifact: "customer-api-server" + branch: "develop" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "customer-api-server" + branch: "stage" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "customer-api-server" + branch: "master" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "customer-web-ui" + branch: "unstable" + tag: "4.1" + - "{artifact}-{branch}-pipeline": + artifact: "customer-web-ui" + branch: "develop" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "customer-web-ui" + branch: "stage" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "customer-web-ui" + branch: "master" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "job-scheduler-server" + branch: "unstable" + tag: "4.1" + - "{artifact}-{branch}-pipeline": + artifact: "job-scheduler-server" + branch: "develop" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "job-scheduler-server" + branch: "stage" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "job-scheduler-server" + branch: "master" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "workflow-server" + branch: "unstable" + tag: "4.1" + - "{artifact}-{branch}-pipeline": + artifact: "workflow-server" + branch: "develop" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "workflow-server" + branch: "stage" + tag: "4.0" + - "{artifact}-{branch}-pipeline": + artifact: "workflow-server" + branch: "master" + tag: "4.0" - job-template: - name: "{artifact}-pipeline" + name: "{artifact}-{branch}-pipeline" project-type: pipeline dsl: | pipeline {{ @@ -25,8 +113,8 @@ stages {{ stage("gradle") {{ steps {{ - git(branch: "unstable", url: "git@github.com:Talligent/{artifact}.git") - sh(script: "/var/lib/jenkins/find_next_tag.sh \$(pwd) {artifact} 4.1") + git(branch: "{branch}", url: "git@github.com:Talligent/{artifact}.git") + sh(script: "/var/lib/jenkins/find_next_tag.sh \$(pwd) {artifact} {tag}") sh(script: "./gradlew -PbuildNumber=\$(cat /tmp/newtag_{artifact}) -PbuildMode=buildProd -Dorg.gradle.daemon=false clean shadowJar") stash(includes: "build/libs/*.jar", name: "jar") }} @@ -35,13 +123,13 @@ steps {{ git(poll: false, branch: "master", url: "git@github.com:Talligent/deployment-scripts.git") unstash(name: "jar") - sh(script: "ruby openbook/ruby/upload_jar.rb --webdav-url=${{WEBDAV_URL}} --webdav-username=${{WEBDAV_USERNAME}} --webdav-password=${{WEBDAV_PASSWORD}} --artifact={artifact} --version=\$(cat /tmp/newtag_{artifact}) --filepath=build/libs/{artifact}.\$(cat /tmp/newtag_{artifact}).jar") + sh(script: "ruby openbook/ruby/upload_jar.rb --webdav-url=${{WEBDAV_URL}} --webdav-username=${{WEBDAV_USERNAME}} --webdav-password=${{WEBDAV_PASSWORD}} --artifact={artifact} --branch={branch} --version=\$(cat /tmp/newtag_{artifact}) --filepath=build/libs/{artifact}.\$(cat /tmp/newtag_{artifact}).jar") }} }} stage("docker-container") {{ steps {{ git(poll: false, branch: "master", url: "git@github.com:Talligent/openbook-v4-ci.git") - sh(script: "./build-docker-containers.sh {artifact}") + sh(script: "./build-docker-containers.sh {artifact} {branch}") }} }} }} diff --git a/pillar/openbook/ansible.sls b/pillar/openbook/ansible.sls index a6495a1..6d7285b 100644 --- a/pillar/openbook/ansible.sls +++ b/pillar/openbook/ansible.sls @@ -166,9 +166,9 @@ ansible: source: inventory_json.rb mode: "0755" is_template: False - deploy_dev_env_sh: - name: deploy-dev-env.sh - source: deploy-dev-env.sh + deploy_branch_sh: + name: deploy-branch.sh + source: deploy-branch.sh mode: "0755" is_template: False openbook_installer_yaml: @@ -191,3 +191,20 @@ ansible: source: find_next_tag.sh mode: "0755" is_template: False + symlinks: + inventory_json_unstable_rb: + name: inventory_json_unstable.rb + target: inventory_json.rb + relative_to_buildroot: True + inventory_json_develop_rb: + name: inventory_json_develop.rb + target: inventory_json.rb + relative_to_buildroot: True + inventory_json_stage_rb: + name: inventory_json_stage.rb + target: inventory_json.rb + relative_to_buildroot: True + inventory_json_master_rb: + name: inventory_json_master.rb + target: inventory_json.rb + relative_to_buildroot: True diff --git a/salt/openbook/admin_api_server/files/installdeps.sh b/salt/openbook/admin_api_server/files/installdeps.sh index e1f2651..a4ac323 100644 --- a/salt/openbook/admin_api_server/files/installdeps.sh +++ b/salt/openbook/admin_api_server/files/installdeps.sh @@ -8,6 +8,6 @@ apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--fo curl -k \ -u '{{ pillar["jars"]["username"] }}:{{ pillar["jars"]["password"] }}' \ -o "{{ pillar["admin_api_server"]["jar_name"] }}" \ - "{{ pillar["jars"]["url"] }}{{ pillar["admin_api_server"]["jar_name"] }}" + "{{ pillar["jars"]["url"] }}/{{ pillar["admin_api_server"]["jar_name"] }}" exit 0 diff --git a/salt/openbook/admin_web_ui/files/installdeps.sh b/salt/openbook/admin_web_ui/files/installdeps.sh index 9485ce1..807b0f7 100644 --- a/salt/openbook/admin_web_ui/files/installdeps.sh +++ b/salt/openbook/admin_web_ui/files/installdeps.sh @@ -8,6 +8,6 @@ apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--fo curl -k \ -u '{{ pillar["jars"]["username"] }}:{{ pillar["jars"]["password"] }}' \ -o "{{ pillar["admin_web_ui"]["jar_name"] }}" \ - "{{ pillar["jars"]["url"] }}{{ pillar["admin_web_ui"]["jar_name"] }}" + "{{ pillar["jars"]["url"] }}/{{ pillar["admin_web_ui"]["jar_name"] }}" exit 0 diff --git a/salt/openbook/ansible/files/deploy-dev-env.sh b/salt/openbook/ansible/files/deploy-branch.sh index b47774e..3a1a72e 100644 --- a/salt/openbook/ansible/files/deploy-dev-env.sh +++ b/salt/openbook/ansible/files/deploy-branch.sh @@ -1,5 +1,6 @@ #!/bin/bash +env="${1}" buildroot="$(pwd)" pushd ${buildroot}/conf @@ -8,5 +9,5 @@ rm -f env.yaml ln -s env.yaml.openbook env.yaml popd pushd ${buildroot} -ansible-playbook -i inventory_json.rb openbook_installer.yaml +ansible-playbook -i inventory_${env}.rb openbook_installer.yaml popd diff --git a/salt/openbook/ansible/files/env.yaml.docker_registry.example b/salt/openbook/ansible/files/env.yaml.docker_registry.example index ccdef39..f00e29c 100644 --- a/salt/openbook/ansible/files/env.yaml.docker_registry.example +++ b/salt/openbook/ansible/files/env.yaml.docker_registry.example @@ -1,10 +1,12 @@ --- globals: ansible_ssh_user: root + ansible_private_key_file: /var/lib/jenkins/.ssh/id_rsa ansible_python_interpreter: /usr/bin/python2 -hosts: - - host1: - cn: ~ - username: ~ - password: ~ +environments: + - master: + - host1: + cn: ~ + username: ~ + password: ~ diff --git a/salt/openbook/ansible/files/env.yaml.openbook.example b/salt/openbook/ansible/files/env.yaml.openbook.example index 9fd4894..ef791ad 100644 --- a/salt/openbook/ansible/files/env.yaml.openbook.example +++ b/salt/openbook/ansible/files/env.yaml.openbook.example @@ -1,25 +1,131 @@ --- globals: ansible_ssh_user: root + ansible_private_key_file: /var/lib/jenkins/.ssh/id_rsa ansible_python_interpreter: /usr/bin/python2 - openbook_gcomm_addresses: ~ - openbook_install_database: True|False - openbook_start_app: True|False -hosts: - - host1: - openbook_database_password: ~ - openbook_customer_web_ui_port: 8080 - openbook_customer_api_server_port: 8081 - openbook_admin_web_ui_port: 8082 - openbook_admin_api_server_port: 8083 - openbook_job_server: True|False - openbook_workflow_server: True|False - - host2: - openbook_database_password: ~ - openbook_customer_web_ui_port: 8080 - openbook_customer_api_server_port: 8081 - openbook_admin_web_ui_port: 8082 - openbook_admin_api_server_port: 8083 - openbook_job_server: True|False - openbook_workflow_server: True|False +environments: + - unstable: + - host1: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - host2: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - develop: + - host1: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - host2: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - stage: + - host1: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - host2: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - master: + - host1: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ + - host2: + openbook_database_password: ~ + openbook_gcomm_addresses: ~ + openbook_install_database: True|False + openbook_start_app: True|False + openbook_install_admin_api_server: True|False + openbook_install_customer_api_server: True|False + openbook_install_admin_web_ui: True|False + openbook_install_customer_web_ui: True|False + openbook_install_job_scheduler_server: True|False + openbook_install_workflow_server: True|False + openbook_admin_web_ui_port: ~ + openbook_admin_api_server_port: ~ + openbook_customer_web_ui_port: ~ + openbook_customer_api_server_port: ~ diff --git a/salt/openbook/ansible/files/env.yaml.openbook_docker_slave.example b/salt/openbook/ansible/files/env.yaml.openbook_docker_slave.example index 72a8549..51592e9 100644 --- a/salt/openbook/ansible/files/env.yaml.openbook_docker_slave.example +++ b/salt/openbook/ansible/files/env.yaml.openbook_docker_slave.example @@ -1,14 +1,16 @@ --- globals: ansible_ssh_user: root - locale: en_US.utf8 + ansible_private_key_file: /var/lib/jenkins/.ssh/id_rsa ansible_python_interpreter: /usr/bin/python2 + locale: en_US.utf8 salt_master: localhost -hosts: - - host1: - database_root_password: ~ - docker_username: ~ - docker_password: ~ - webdav_username: ~ - webdav_password: ~ +environments: + - master: + - host1: + database_root_password: ~ + docker_username: ~ + docker_password: ~ + webdav_username: ~ + webdav_password: ~ diff --git a/salt/openbook/ansible/files/inventory_json.rb b/salt/openbook/ansible/files/inventory_json.rb index 8a01004..e4a5938 100644 --- a/salt/openbook/ansible/files/inventory_json.rb +++ b/salt/openbook/ansible/files/inventory_json.rb @@ -9,23 +9,38 @@ def doit() STDERR.puts "Unable to find env.yaml. Exiting." exit(1) end + environ = "" + ["unstable", "develop", "stage", "master"].each do |env| + if File.basename($0).include?(env) + environ = env + break + end + end + if environ == "" + STDERR.puts "Unable to determine environment. Exiting." + exit(1) + end globs = {} hostvars = {} outobj = {} - hosts = [] + hosts_arr = [] yml = YAML.load_file(env_yaml_path) yml["globals"].each do |key, value| globs[key] = value end - yml["hosts"].each do |h| - h.each do |host, attributes| - hosts.push(host) - attributes.each do |attribute, value| - hostvars[host] = globs.merge(attributes) + yml["environments"].each do |ee| + ee.each do |e, hosts| + if e == environ + hosts.each do |host_hash| + host_hash.each do |host, attributes| + hosts_arr.push(host) + hostvars[host] = globs.merge(attributes) + end + end end end end - outobj["target"] = {"hosts" => hosts} + outobj["target"] = {"hosts" => hosts_arr} outobj["_meta"] = {"hostvars" => hostvars} puts outobj.to_json end diff --git a/salt/openbook/ansible/init.sls b/salt/openbook/ansible/init.sls index e337964..b446c33 100644 --- a/salt/openbook/ansible/init.sls +++ b/salt/openbook/ansible/init.sls @@ -1,5 +1,5 @@ {% for dir in pillar["ansible"]["dirs"].items() %} -anaible_dirs_{{ dir[0] }}: +ansible_dirs_{{ dir[0] }}: file.directory: {% if dir[1]["relative_to_buildroot"] %} - name: {{ pillar["ansible"]["build_dir"] }}/{{ dir[1]["name"] }} @@ -12,6 +12,18 @@ anaible_dirs_{{ dir[0] }}: - makedirs: True {% endfor %} +{% for symlink in pillar["ansible"]["symlinks"].items() %} +ansible_symlinks_{{ symlink[0] }}: + file.symlink: +{% if symlink[1]["relative_to_buildroot"] %} + - name: {{ pillar["ansible"]["build_dir"] }}/{{ symlink[1]["name"] }} + - target: {{ pillar["ansible"]["build_dir"] }}/{{ symlink[1]["target"] }} +{% else %} + - name: {{ symlink[1]["name"] }} + - target: {{ symlink[1]["target"] }} +{% endif %} +{% endfor %} + {% for file in pillar["ansible"]["files"].items() %} ansible_files_{{ file[0] }}: file.managed: @@ -24,4 +36,3 @@ ansible_files_{{ file[0] }}: - group: root - mode: {{ file[1]["mode"] }} {% endfor %} - diff --git a/salt/openbook/ci/files/build.sh b/salt/openbook/ci/files/build.sh index 3faef38..abcba51 100644 --- a/salt/openbook/ci/files/build.sh +++ b/salt/openbook/ci/files/build.sh @@ -1,5 +1,7 @@ #!/bin/bash +artifact="${1}" + for i in $(docker images | grep -v CREATED | awk '{print $3}'); do docker rmi --force $i done @@ -16,19 +18,19 @@ docker login --username {{ pillar["registry"]["username"] }} --password {{ pilla # curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' -X DELETE https://{{ pillar["registry"]["url"] }}/v2/${i}/manifests/${digest} # done -if [ "${1}" == "database" ]; then +if [ "${artifact}" == "database" ]; then {{ pillar["database"]["build_dir"] }}/build.sh -elif [ "${1}" == "admin-api-server" ]; then +elif [ "${artifact}" == "admin-api-server" ]; then {{ pillar["admin_api_server"]["build_dir"] }}/build.sh -elif [ "${1}" == "customer-api-server" ]; then +elif [ "${artifact}" == "customer-api-server" ]; then {{ pillar["customer_api_server"]["build_dir"] }}/build.sh -elif [ "${1}" == "admin-web-ui" ]; then +elif [ "${artifact}" == "admin-web-ui" ]; then {{ pillar["admin_web_ui"]["build_dir"] }}/build.sh -elif [ "${1}" == "customer-web-ui" ]; then +elif [ "${artifact}" == "customer-web-ui" ]; then {{ pillar["customer_web_ui"]["build_dir"] }}/build.sh -elif [ "${1}" == "job-scheduler-server" ]; then +elif [ "${artifact}" == "job-scheduler-server" ]; then {{ pillar["job_scheduler_server"]["build_dir"] }}/build.sh -elif [ "${1}" == "workflow-server" ]; then +elif [ "${artifact}" == "workflow-server" ]; then {{ pillar["workflow_server"]["build_dir"] }}/build.sh else {{ pillar["database"]["build_dir"] }}/build.sh diff --git a/salt/openbook/customer_api_server/files/installdeps.sh b/salt/openbook/customer_api_server/files/installdeps.sh index e0dc20f..d14d7a2 100644 --- a/salt/openbook/customer_api_server/files/installdeps.sh +++ b/salt/openbook/customer_api_server/files/installdeps.sh @@ -8,6 +8,6 @@ apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--fo curl -k \ -u '{{ pillar["jars"]["username"] }}:{{ pillar["jars"]["password"] }}' \ -o "{{ pillar["customer_api_server"]["jar_name"] }}" \ - "{{ pillar["jars"]["url"] }}{{ pillar["customer_api_server"]["jar_name"] }}" + "{{ pillar["jars"]["url"] }}/{{ pillar["customer_api_server"]["jar_name"] }}" exit 0 diff --git a/salt/openbook/customer_web_ui/files/installdeps.sh b/salt/openbook/customer_web_ui/files/installdeps.sh index 7ec1f67..e1a5532 100644 --- a/salt/openbook/customer_web_ui/files/installdeps.sh +++ b/salt/openbook/customer_web_ui/files/installdeps.sh @@ -8,6 +8,6 @@ apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--fo curl -k \ -u '{{ pillar["jars"]["username"] }}:{{ pillar["jars"]["password"] }}' \ -o "{{ pillar["customer_web_ui"]["jar_name"] }}" \ - "{{ pillar["jars"]["url"] }}{{ pillar["customer_web_ui"]["jar_name"] }}" + "{{ pillar["jars"]["url"] }}/{{ pillar["customer_web_ui"]["jar_name"] }}" exit 0 diff --git a/salt/openbook/job_scheduler_server/files/installdeps.sh b/salt/openbook/job_scheduler_server/files/installdeps.sh index 27f0936..64ba328 100644 --- a/salt/openbook/job_scheduler_server/files/installdeps.sh +++ b/salt/openbook/job_scheduler_server/files/installdeps.sh @@ -8,6 +8,6 @@ apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--fo curl -k \ -u '{{ pillar["jars"]["username"] }}:{{ pillar["jars"]["password"] }}' \ -o "{{ pillar["job_scheduler_server"]["jar_name"] }}" \ - "{{ pillar["jars"]["url"] }}{{ pillar["job_scheduler_server"]["jar_name"] }}" + "{{ pillar["jars"]["url"] }}/{{ pillar["job_scheduler_server"]["jar_name"] }}" exit 0 diff --git a/salt/openbook/workflow_server/files/installdeps.sh b/salt/openbook/workflow_server/files/installdeps.sh index adb184f..2bba1b0 100644 --- a/salt/openbook/workflow_server/files/installdeps.sh +++ b/salt/openbook/workflow_server/files/installdeps.sh @@ -8,6 +8,6 @@ apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--fo curl -k \ -u '{{ pillar["jars"]["username"] }}:{{ pillar["jars"]["password"] }}' \ -o "{{ pillar["workflow_server"]["jar_name"] }}" \ - "{{ pillar["jars"]["url"] }}{{ pillar["workflow_server"]["jar_name"] }}" + "{{ pillar["jars"]["url"] }}/{{ pillar["workflow_server"]["jar_name"] }}" exit 0 |
