Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/setup_etcd3/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # setup etcd3 for integration tests on module/lookup
8 # Copyright (c) 2017, Jean-Philippe Evrard <[email protected]>
9 # Copyright (c) 2020, SCC France, Eric Belhomme <[email protected]>
10 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
11 # SPDX-License-Identifier: GPL-3.0-or-later
12
13 - name: Install etcd3 Python library
14 ansible.builtin.pip:
15 name: "{{ etcd3_pip_module }}"
16 state: present
17
18 - name: Check if etcdctl is already usable
19 ansible.builtin.command: "{{ etcd3_path }}/etcdctl --endpoints=localhost:2379 endpoint health"
20 changed_when: false
21 failed_when: false
22 register: etcd3_health_check
23
24 - name: Set up etcd3 binary
25 when: etcd3_health_check.rc != 0
26 block:
27 - name: Ensure clean download directory
28 ansible.builtin.file:
29 path: "{{ etcd3_download_location }}"
30 state: absent
31
32 - name: Create download directory
33 ansible.builtin.file:
34 path: "{{ etcd3_download_location }}"
35 state: directory
36
37 - name: Download etcd3
38 ansible.builtin.unarchive:
39 src: "{{ etcd3_download_url }}"
40 dest: "{{ etcd3_download_location }}"
41 remote_src: true
42
43 - name: Start etcd3
44 ansible.builtin.shell: "nohup {{ etcd3_path }}/etcd > /tmp/etcd3.log 2>&1 &"
45 changed_when: true
46
47 - name: Wait for etcd3 to be ready
48 ansible.builtin.command: "{{ etcd3_path }}/etcdctl --endpoints=localhost:2379 endpoint health"
49 register: etcd3_ready
50 until: etcd3_ready.rc == 0
51 retries: 10
52 delay: 3
53 changed_when: false