1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/consul/tasks/main.yml

98 lines
3.6 KiB
YAML
Raw Normal View History

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
2020-03-09 10:11:07 +01:00
- name: Install Consul and test
vars:
consul_version: 1.13.2
consul_uri: https://releases.hashicorp.com/consul/{{ consul_version }}/consul_{{ consul_version }}_{{ ansible_system | lower }}_{{ consul_arch }}.zip
consul_cmd: '{{ remote_tmp_dir }}/consul'
2020-03-09 10:11:07 +01:00
block:
- name: Install requests<2.20 (CentOS/RHEL 6)
pip:
name: requests<2.20
extra_args: "-c {{ remote_constraints }}"
2020-03-09 10:11:07 +01:00
register: result
until: result is success
when: ansible_distribution_file_variety|default() == 'RedHat' and ansible_distribution_major_version is version('6', '<=')
- name: Install python-consul
pip:
name: python-consul
extra_args: "-c {{ remote_constraints }}"
2020-03-09 10:11:07 +01:00
register: result
until: result is success
- name: Generate privatekey
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/privatekey.pem'
- name: Generate CSR
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/csr.csr'
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
subject:
commonName: localhost
- name: Generate selfsigned certificate
register: selfsigned_certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/cert.pem'
csr_path: '{{ remote_tmp_dir }}/csr.csr'
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
provider: selfsigned
selfsigned_digest: sha256
2020-03-09 10:11:07 +01:00
- name: Install unzip
package:
name: unzip
register: result
until: result is success
when: ansible_distribution != "MacOSX"
- assert:
that: ansible_architecture in ['i386', 'x86_64', 'amd64']
- set_fact:
consul_arch: '386'
when: ansible_architecture == 'i386'
- set_fact:
consul_arch: amd64
when: ansible_architecture in ['x86_64', 'amd64']
- name: Download consul binary
unarchive:
src: '{{ consul_uri }}'
dest: '{{ remote_tmp_dir }}'
2020-03-09 10:11:07 +01:00
remote_src: true
register: result
until: result is success
- vars:
remote_dir: '{{ echo_remote_tmp_dir.stdout }}'
2020-03-09 10:11:07 +01:00
block:
- command: echo {{ remote_tmp_dir }}
register: echo_remote_tmp_dir
2020-03-09 10:11:07 +01:00
- name: Create configuration file
template:
src: consul_config.hcl.j2
dest: '{{ remote_tmp_dir }}/consul_config.hcl'
2020-03-09 10:11:07 +01:00
- name: Start Consul (dev mode enabled)
shell: nohup {{ consul_cmd }} agent -dev -config-file {{ remote_tmp_dir }}/consul_config.hcl </dev/null >/dev/null 2>&1 &
- name: Bootstrap ACL
command: '{{ consul_cmd }} acl bootstrap --format=json'
register: consul_bootstrap_result_string
- set_fact:
consul_management_token: '{{ consul_bootstrap_json_result["SecretID"] }}'
vars:
consul_bootstrap_json_result: '{{ consul_bootstrap_result_string.stdout | from_json }}'
2020-03-09 10:11:07 +01:00
- name: Create some data
command: '{{ consul_cmd }} kv put -token={{consul_management_token}} data/value{{ item }} foo{{ item }}'
2020-03-09 10:11:07 +01:00
loop:
- 1
- 2
- 3
- import_tasks: consul_session.yml
- import_tasks: consul_policy.yml
[PR #6972/d0f229f5 backport][stable-7] Add consul_role module from domant PR (#7282) Add consul_role module from domant PR (#6972) * Update as per PR comments * Move common code to module_utils * Break up long import line * Fix pipeline errors * Inital version of check_mode support * Fix updating a role, add tests * Fix line spacing * Fix line indentation * Add consul-role tests * Fixes for role update * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Update as per MR comments * Update as per MR comments * Fix documentation issues * Add types for sub-options * Allow setting of policy, service and node id fields by specifying a value, or leaving them unchanged by omitting them * Fix typo in test * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Reset and force push to get rid of merge * Corrected unit tests * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Add suboptions documentation for node and service identities * Fix PEP errors from pipeline * Fix pipeline errors. * Fix more pipeline errors * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Fix line that is too long * Not specifying a value for description during update now leaves existing value unchanged * Fixes for pipeline errors * Add test cases to verify handling description works --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit d0f229f5d8eb89f5e4d6858deb6ce90675d37908) Co-authored-by: Valerio Poggi <106782233+valeriopoggi@users.noreply.github.com>
2023-09-17 14:51:07 +02:00
- import_tasks: consul_role.yml
2020-03-09 10:11:07 +01:00
always:
- name: Kill consul process
shell: kill $(cat {{ remote_tmp_dir }}/consul.pid)
ignore_errors: true