diff --git a/defaults/main.yml b/defaults/main.yml index 928e32f0..adb9fe84 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,6 +26,9 @@ rabbitmq_host_group: "rabbitmq_all" # The local address used for the rabbitmq cluster node rabbitmq_node_address: "{{ ansible_host }}" +rabbit_system_user_name: rabbitmq +rabbit_system_group_name: rabbitmq + # Hosts file entries (set this to an empty list to disable /etc/hosts generation # for the rabbitmq cluster nodes) rabbitmq_hosts_entries: >- diff --git a/tasks/rabbitmq_post_install.yml b/tasks/rabbitmq_post_install.yml index a40d8fdf..45da1685 100644 --- a/tasks/rabbitmq_post_install.yml +++ b/tasks/rabbitmq_post_install.yml @@ -28,6 +28,8 @@ template: src: "{{ item.src }}" dest: "{{ item.dest }}" + owner: "{{ rabbit_system_user_name }}" + group: "{{ rabbit_system_group_name }}" with_items: - { src: "rabbitmq.config.j2", dest: "/etc/rabbitmq/rabbitmq.config" } - { src: "rabbitmq-server.j2", dest: "/etc/default/rabbitmq-server" } diff --git a/tasks/rabbitmq_pre_install.yml b/tasks/rabbitmq_pre_install.yml index 22bb49ef..393dc6a2 100644 --- a/tasks/rabbitmq_pre_install.yml +++ b/tasks/rabbitmq_pre_install.yml @@ -48,12 +48,28 @@ tags: - rabbitmq-config +- name: Create the system group + group: + name: "{{ rabbit_system_group_name }}" + state: "present" + system: "yes" + +- name: Create the rabbit system user + user: + name: "{{ rabbit_system_user_name }}" + group: "{{ rabbit_system_group_name }}" + comment: "RabbitMQ messaging server" + shell: "/bin/false" + system: "yes" + createhome: "yes" + home: "/var/lib/rabbitmq" + - name: Create the local directories file: path: "/etc/rabbitmq/" state: "directory" - group: "root" - owner: "root" + group: "{{ rabbit_system_user_name }}" + owner: "{{ rabbit_system_group_name }}" mode: "0755" tags: - rabbitmq-config diff --git a/templates/rabbitmq-server.service.j2 b/templates/rabbitmq-server.service.j2 index 3da3689d..603403f2 100644 --- a/templates/rabbitmq-server.service.j2 +++ b/templates/rabbitmq-server.service.j2 @@ -6,8 +6,8 @@ Conflicts=epmd.service [Service] Type=notify -User=rabbitmq -Group=rabbitmq +User={{ rabbit_system_user_name }} +Group={{ rabbit_system_group_name }} LimitNOFILE=65535 NotifyAccess=all WorkingDirectory=/var/lib/rabbitmq diff --git a/vars/redhat.yml b/vars/redhat.yml index 4d3946d0..18fea72f 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -31,5 +31,5 @@ _rabbitmq_erlang_repo: filename: els-erlang rabbitmq_distro_packages: - - erlang-22.3-1.el7.x86_64 - - "rabbitmq-server-{{ rabbitmq_package_version }}.el7.noarch" + - "erlang-22.3-1.el{{ ansible_distribution_major_version }}.x86_64" + - "rabbitmq-server-{{ rabbitmq_package_version }}.el{{ ansible_distribution_major_version }}.noarch"