prototypes: fix yamllint issues
[releng.git] / utils / test / testapi / 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     mode: "pull"
12     mongodb_url: "mongodb://172.17.0.1:27017"
13     swagger_url: "http://{{ host }}:{{ port }}"
14   tasks:
15     - name: create temporary update directory
16       file:
17         path: "{{ update_path }}"
18         state: directory
19     - name: transfer files in templates
20       copy:
21         src: templates/
22         dest: "{{ update_path }}"
23     - name: transfer Dockerfile
24       copy:
25         src: ../docker/Dockerfile
26         dest: "{{ update_path }}"
27       when: mode == "build"
28     - name: backup mongodb database
29       command: "python {{ update_path }}/backup_mongodb.py -u {{ mongodb_url }} -o {{ update_path }}"
30     - name: stop and remove old versions
31       command: bash "{{ update_path }}/rm_olds.sh"
32       register: rm_result
33     - debug: msg="{{ rm_result.stderr }}"
34     - name: delete old docker images
35       command: bash "{{ update_path }}/rm_images.sh"
36       ignore_errors: true
37     - name: update mongodb
38       command: "python {{ update_path }}/update_mongodb.py -u {{ mongodb_url }}"
39     - name: docker build image
40       command: "docker build -t {{ image }} {{ update_path }}"
41       when: mode == "build"
42     - name: docker start testapi server
43       command: docker run -dti -p "{{ port }}:8000"
44                -e "mongodb_url={{ mongodb_url }}"
45                -e "swagger_url={{ swagger_url }}"
46                "{{ image }}"
47     - name: remove temporary update directory
48       file:
49         path: "{{ update_path }}"
50         state: absent