Added seed code for caas-etcd.
[ta/caas-etcd.git] / ansible / roles / etcd / tasks / wait_for_etcd.yml
1 ---
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 - set_fact:
17     counter_wait_for: "{{ item.0 }}"
18
19 - set_fact:
20     current_oam_wait_for: "{{ item.1 }}"
21
22 - set_fact:
23     etcd_number_wait_for: "{{ counter_wait_for | int + 2 }}"
24
25 - set_fact:
26     expexted_oam_to_run: "caas_master{{ counter_wait_for | int + 2 }}"
27
28 - name: wait for a running etcd on caas_master node from the next caas_master nodes
29   shell: "/usr/bin/curl https://{{ hostvars[current_oam_wait_for]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_api_port }}/health --cacert /etc/etcd/ssl/ca.pem --cert /etc/etcd/ssl/etcd{{ etcd_number_wait_for }}.pem --key /etc/etcd/ssl/etcd{{ etcd_number_wait_for }}-key.pem"
30   register: result
31   until: ( result.stdout.find('true') != -1 ) or ( result.stdout.find('false') != -1 )
32   retries: 500
33   delay: 6
34   when:  nodename | search( expexted_oam_to_run )
35   become_user: "root"
36