auto update of testAPI using ansible-playbook
[releng.git] / utils / test / result_collection_api / update / update.yml
1 ---
2 - hosts: "{{ host }}"
3   remote_user: "{{ user }}"
4   become: yes
5   become_method: sudo
6   vars:
7     user: "root"
8     port: "8000"
9     update_path: "/tmp/testapi"
10     image: "opnfv/testapi"
11     mongodb_url: "mongodb://172.17.0.1:27017"
12     swagger_url: "http://{{ host }}:{{ port }}"
13   tasks:
14     - name: create temporary update directory
15       file:
16         path: "{{ update_path }}"
17         state: directory
18     - name: transfer files in templates
19       copy:
20         src: templates/
21         dest: "{{ update_path }}"
22     - name: backup mongodb database
23       command: "python {{ update_path }}/backup_mongodb.py -u {{ mongodb_url }} -o {{ update_path }}"
24     - name: stop and remove old versions
25       command: bash "{{ update_path }}/rm_olds.sh"
26       register: rm_result
27     - debug: msg="{{ rm_result.stderr }}"
28     - name: delete old docker images
29       command: docker rmi "{{ image }}"
30       ignore_errors: true
31     - name: update mongodb
32       command: "python {{ update_path }}/update_mongodb.py -u {{ mongodb_url }}"
33     - name: docker start testapi server
34       command: docker run -dti -p "{{ port }}:8000"
35                -e "mongodb_url={{ mongodb_url }}"
36                -e "swagger_url={{ swagger_url }}"
37                "{{ image }}"
38     - name: remove temporary update directory
39       file:
40         path: "{{ update_path }}"
41         state: absent