2 - name: create rabbitmq directory
3 file: path=/etc/rabbitmq state=directory mode=0755
5 - name: copy rabbitmq config file
6 template: src=rabbitmq-env.conf dest=/etc/rabbitmq/rabbitmq-env.conf mode=0755
8 - name: install rabbitmq-server
9 apt: name=rabbitmq-server state=present
11 - name: stop rabbitmq-server
12 service: name=rabbitmq-server
15 - name: update .erlang.cookie
16 template: src=.erlang.cookie dest=/var/lib/rabbitmq/.erlang.cookie
20 when: ERLANG_TOKEN is defined
22 - name: start and enable rabbitmq-server
23 service: name=rabbitmq-server
27 - name: generate mq service list
28 shell: echo {{ item }} >> /opt/service
32 - name: modify rabbitmq password
33 command: rabbitmqctl change_password guest {{ RABBIT_PASS }}
34 when: "RABBIT_USER is defined and RABBIT_USER == 'guest'"
37 - name: add rabbitmq user
38 command: rabbitmqctl add_user {{ RABBIT_USER }} {{ RABBIT_PASS }}
39 when: "RABBIT_USER is defined and RABBIT_USER != 'guest'"
42 - name: set rabbitmq user permission
43 command: rabbitmqctl set_permissions -p / {{ RABBIT_USER }} ".*" ".*" ".*"
44 when: "RABBIT_USER is defined and RABBIT_USER != 'guest'"