Skip to content

Instantly share code, notes, and snippets.

@onlyanegg
Last active September 12, 2016 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onlyanegg/2779479652b7e5d50b5c819f92441a94 to your computer and use it in GitHub Desktop.
Save onlyanegg/2779479652b7e5d50b5c819f92441a94 to your computer and use it in GitHub Desktop.
stop_internal_services:
service.dead:
- name: internal_services
{% for artifact in pillar.internal_services.artifacts.zips %}
undeploy_exploded_{{ artifact }}:
file.absent:
- name: {{ pillar.internal_services.install_dir }}/{{ artifact }}
deploy_new_{{ artifact }}:
cmd.run:
- name: curl --user '{{ pillar.bamboo.user }}:{{ pillar.bamboo.passwd }}' --insecure {{ pillar.bamboo.url }}/PRODUCTION-PLATFORM-{{ pillar.internal_services.release }}/artifact/shared/dist/{{ artifact }}.zip --fail -o {{ artifact }}.zip
- cwd: {{ pillar.internal_services.install_dir }}
- runas: {{ pillar.sys_users.internal_services.user }}
unzip_{{ artifact }}:
cmd.run:
- name: unzip -d {{ artifact }} {{ artifact }}.zip
- cwd: {{ pillar.internal_services.install_dir }}
- runas: {{ pillar.sys_users.internal_services.user }}
make_sh_script_from_{{ artifact }}_executable:
file.managed:
- name: {{ pillar.internal_services.install_dir }}/{{ artifact }}/{{ artifact }}/{{ artifact }}_run.sh
- mode: 755
{% endfor %}
{% for artifact in pillar.internal_services.artifacts.jars %}
deploy_new_{{ artifact }}:
cmd.run:
- name: curl --user '{{ pillar.bamboo.user }}:{{ pillar.bamboo.passwd }}' --insecure {{ pillar.bamboo.url }}/PRODUCTION-PLATFORM-{{ pillar.internal_services.release }}/artifact/shared/dist/{{ artifact }}.jar --fail -o {{ artifact }}.jar
- cwd: {{ pillar.internal_services.install_dir }}
- runas: {{ pillar.sys_users.internal_services.user }}
{% endfor %}
{% for artifact in pillar.internal_services.artifacts.wars %}
deploy_new_{{ artifact }}:
cmd.run:
- name: curl --user '{{ pillar.bamboo.user }}:{{ pillar.bamboo.passwd }}' --insecure {{ pillar.bamboo.url }}/PRODUCTION-PLATFORM-{{ pillar.internal_services.release }}/artifact/shared/dist/{{ artifact }}.war --fail -o {{ artifact }}.war
- cwd: {{ pillar.internal_services.install_dir }}
- runas: {{ pillar.sys_users.internal_services.user }}
{% endfor %}
start_internal_services:
service.running:
- name: internal_services
deploy:
environment: local
pods:
- pod1
internal_services:
revision: 825
branch: minor
external_services:
revision: 825
branch: minor
{% for pod in pillar.deploy.pods %}
{% if pillar.deploy.internal_services is defined and pillar.deploy.external_services is defined %}
deploy_internal_and_external_services:
salt.state:
- tgt: plat[0-9]{2,3}.{{ pod }}.{{ pillar.deploy.environment }}.*
- tgt_type: pcre
- saltenv: common
- batch: 50%
- sls:
- deploy.internal_services
- deploy.external_services
{% endif %}
{% endfor %}
[root@mgmt01 states]# salt-run --state-output=full state.orchestrate deploy test=true saltenv=common pillar='{"deploy":{"environment":"local","pods":["pod1"],"internal_services":{"revision":825,"branch":"minor"},"external_services":{"revision":825,"branch":"minor"}}}'
[WARNING ] /usr/lib/python2.7/site-packages/salt/grains/core.py:1493: DeprecationWarning: The "osmajorrelease" will be a type of an integer.
mgmt01.pod1.local.or.certainaws.com_master:
----------
ID: deploy_internal_and_external_services
Function: salt.state
Result: True
Comment: States ran successfully.
Started: 17:07:40.904780
Duration: 15133.359 ms
Changes:
Summary for mgmt01.pod1.local.or.certainaws.com_master
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 15.133 s
[root@mgmt01 deploy]# salt-key
Accepted Keys:
mgmt01.pod1.local.or.example.com
plat01.pod1.local.or.example.com
Denied Keys:
Unaccepted Keys:
Rejected Keys:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment