ansible-community / ansible-nomad

:watch: Ansible role for Nomad
https://galaxy.ansible.com/brianshumate/nomad
BSD 2-Clause "Simplified" License
294 stars 163 forks source link

Role specific configuration file is not removed when role is no longer used #120

Closed ygalblum closed 3 years ago

ygalblum commented 3 years ago

Info

In some scenarios I need to change the role of an instance from "both" or "server" to "client". However, the role does not remove the server.hcl file. As a result, when the service is restarted it still acts as a server

Steps to reproduce

  1. Provision an initial cluster with more that one server. For example, 4 instances all configured to "both"
  2. Check that the cluster has 4 servers and 4 clients
  3. Change the inventory file so that the role of one of them is changed to "client"
  4. Run the playbook

Expected results

The cluster now has 3 servers and 4 clients

Actual results

The cluster still has 4 servers and 4 clients

Root cause

The role only creates the server.hcl when needed, but does not verify its absent when it is not. The fix is to add a task that ensures absent if the instance is not a server. The same should be done for the client.hcl

I can open a PR for it

lanefu commented 3 years ago

Nice enhancement... PR's always :)