1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-06 01:55:51 +00:00
community.general/tests/integration/targets/nomad/tasks/main.yml
patchback[bot] c2129d331b
[PR #11956/7b05c052 backport][stable-12] nomad: re-enable tests (#11960)
nomad: re-enable tests (#11956)

* nomad: re-enable tests

* test(nomad): revamp integration tests

- bump nomad to 2.0.0
- update job.hcl to Nomad 1.x+ HCL syntax
- add macOS support: skip unzip install on Darwin, add arm64/aarch64 arch mapping
- skip Alpine in aliases instead of runtime gate in main.yml
- move nomad_version/nomad_cmd/nomad_uri/arch_map to role vars
- flatten block structure



---------


(cherry picked from commit 7b05c05205)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:50:20 +02:00

78 lines
2 KiB
YAML

---
# 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
# Skip Alpine (Nomad official binaries are glibc-linked, Alpine uses musl)
# Skip MacOS because of how complicated it is to run an downloaded binary
- name: Skip unsupported platforms
meta: end_play
when: >
ansible_facts.distribution == 'Alpine'
or ansible_facts.os_family == 'Darwin'
- name: Install python-nomad
pip:
name: python-nomad
extra_args: "-c {{ remote_constraints }}"
register: result
until: result is success
- name: Install jmespath
pip:
name: jmespath
extra_args: "-c {{ remote_constraints }}"
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
- name: Install unzip
package:
name: unzip
register: result
until: result is success
- name: Download nomad binary
unarchive:
src: '{{ nomad_uri }}'
dest: '{{ remote_tmp_dir }}'
remote_src: true
register: result
until: result is success
- name: Run tests integration
block:
- name: Start nomad (dev mode enabled)
shell: nohup {{ nomad_cmd }} agent -dev </dev/null >/dev/null 2>&1 &
- name: wait nomad up
wait_for:
host: localhost
port: 4646
delay: 10
timeout: 60
- import_tasks: nomad_job.yml
always:
- name: kill nomad
shell: pkill nomad