Commit 969693e7 authored by Pavlos Daoglou's avatar Pavlos Daoglou

Merge pull request #67 from pkoro/argo-393

ARGO-393 Changes in swagger role
parents 9d461ecf 84e86e54
--- ---
swagger_ui_host: example.com swagger_docs:
swagger_ui_port: 8080 - { github_org: swagger-api, name: swagger-spec , branch: master, path_to_yaml: "examples/v2.0/yaml/petstore.yaml" , api_host: "petstore.swagger.io"}
swagger_web_api_branch: devel
swagger_messaging_branch: devel
---
- name: restart apache
service: name=httpd state=restarted
...@@ -10,13 +10,10 @@ ...@@ -10,13 +10,10 @@
- name: Install Apache - name: Install Apache
tags: swagger tags: swagger
yum: name=httpd state=present yum: name={{ item }} state=present
with_items:
- name: Config Apache to run on specified port - httpd
tags: swagger - mod_ssl
lineinfile: dest=/etc/httpd/conf/httpd.conf regexp="^Listen "
insertafter="^#Listen " line="Listen {{ swagger_ui_port }}"
notify: restart apache
- name: Config Apache Up and Running - name: Config Apache Up and Running
tags: swagger tags: swagger
...@@ -32,53 +29,48 @@ ...@@ -32,53 +29,48 @@
curl -L https://api.github.com/repos/swagger-api/swagger-ui/tarball curl -L https://api.github.com/repos/swagger-api/swagger-ui/tarball
| tar xz -C /tmp/swagger --strip-components 1 | tar xz -C /tmp/swagger --strip-components 1
- name: Create argo-web-api swagger dir - name: Create swagger directories
tags: swagger tags: swagger
file: path={{item}} state=directory file: path=/var/www/html/{{ item.name }} state=directory owner=root group=root mode=0755
with_items: with_items: swagger_docs
- /var/www/html/argo-web-api
- /var/www/html/argo-messaging
- name: Transfer dist files to each dedicated dir at /var/www/html/ - name: Transfer dist files to each dedicated dir at /var/www/html/
tags: swagger tags: swagger
shell: cp -R /tmp/swagger/dist/* {item} shell: cp -R /tmp/swagger/dist/* /var/www/html/{{ item.name }}
with_items: with_items: swagger_docs
- /var/www/html/argo-web-api
- /var/www/html/argo-messaging
- name: Get latest argo-web-api swagger.yaml from our devel repo - name: Get latest swagger.yaml definition files
tags: swagger tags: swagger
command: > get_url: url=https://raw.githubusercontent.com/{{ item.github_org }}/{{ item.name }}/{{ item.branch }}/{{ item.path_to_yaml }}
curl -L -H "Accept: application/vnd.github.raw" dest=/tmp/swagger/{{ item.name }}_swagger.yaml force=yes
https://api.github.com/repositories/17568185/contents/doc/swagger/swagger.yaml?ref={{swagger_web_api_branch}} owner=root group=root mode=0644
-o /tmp/swagger/argo-web-api_swagger.yaml with_items: swagger_docs
notify: restart apache
- name: Convert argo-web-api swagger.yaml to swagger.json - name: Convert swagger.yaml to swagger.json
tags: swagger tags: swagger
shell: > shell: >
python -c 'import sys, yaml, json; python -c 'import sys, yaml, json;
json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)'
< /tmp/swagger/argo-web-api_swagger.yaml > /var/www/html/argo-web-api/swagger.json < /tmp/swagger/{{ item.name }}_swagger.yaml > /var/www/html/{{ item.name }}/swagger.json
with_items: swagger_docs
- name: Point argo-web-api swagger-ui to our own swagger.yaml definition - name: Make swagger.json point to corresponding api endpoint
tags: swagger tags: swagger
replace: dest=/var/www/html/argo-web-api/index.html regexp='url = "http:\/\/petstore\.swagger\.io\/v2\/swagger\.json";' replace='url = "http://{{ swagger_ui_host }}:{{ swagger_ui_port }}/argo-web-api/swagger.json";' backup=yes lineinfile: >
dest=/var/www/html/{{ item.name }}/swagger.json
regexp='( +)\"host\":\ \"(.+)\"\,'
line=' \"host\": \"{{ item.api_host }}\",'
state=present backup=yes
with_items: swagger_docs
notify: restart apache
- name: Get latest argo-messaging swagger.yaml from our devel repo - name: Point swagger-ui to corresponding swagger definitions on host
tags: swagger tags: swagger
command: > replace: dest=/var/www/html/{{ item.name }}/index.html
curl -L -H "Accept: application/vnd.github.raw" regexp='url = "http:\/\/petstore\.swagger\.io\/v2\/swagger\.json";'
https://api.github.com/repositories/17568185/contents/doc/swagger/swagger.yaml?ref={{swagger_messaging_branch}} replace='url = "https://{{ inventory_hostname }}/{{ item.name }}/swagger.json";'
-o /tmp/swagger/argo-messaging_swagger.yaml backup=yes
with_items: swagger_docs
- name: Convert argo-messaging swagger.yaml to swagger.json
tags: swagger
shell: >
python -c 'import sys, yaml, json;
json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)'
< /tmp/swagger/argo-messaging_swagger.yaml > /var/www/html/argo-web-api/swagger.json
- name: Point argo-messaging swagger-ui to our own swagger.yaml definition
tags: swagger
replace: dest=/var/www/html/argo-messaging/index.html regexp='url = "http:\/\/petstore\.swagger\.io\/v2\/swagger\.json";' replace='url = "http://{{ swagger_ui_host }}:{{ swagger_ui_port }}/argo-messaging/swagger.json";' backup=yes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment