diff --git a/tasks/rabbitmq_pre_install.yml b/tasks/rabbitmq_pre_install.yml index 96cc4f0e..a2431e6e 100644 --- a/tasks/rabbitmq_pre_install.yml +++ b/tasks/rabbitmq_pre_install.yml @@ -44,14 +44,20 @@ lineinfile: dest: /etc/hosts state: present - line: > - {{ hostvars[item]['ansible_ssh_host'] }} - {{ hostvars[item]['ansible_hostname'] }} - {% if hostvars[item]['ansible_hostname'] != 'localhost' %}{{ hostvars[item]['ansible_hostname'].split('.')[0] }}{% endif %} + line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}" with_items: "{{ groups[rabbitmq_host_group] }}" tags: - rabbitmq-config +- name: Ensure localhost /etc/hosts entry is correct + lineinfile: + dest: /etc/hosts + state: present + line: '127.0.0.1 localhost' + regexp: '^127.0.0.1' + tags: + - rabbitmq-config + - name: Create the local directories file: path: "/etc/rabbitmq/"