ansible自動安裝rabbitmq

2022-03-19 01:30:14 字數 1998 閱讀 9020

ansible playbook 安裝rabbitmq單機版,以下指令碼在centos6.7伺服器測試通過。

需要配置本機的yum源,用於安裝socat軟體。

可以根據自己需要選擇rabbitmq版本(但要到官網查詢支援的erlang,否則安裝後無法啟動)

1

---2

3gather_facts: false

4hosts: "}"

5user: root

6tasks:

7- name: time sync

8command: /usr/sbin/ntpdate 10.86.1.76910

- name: install require rpm packages

11yum: name=socat state=installed

1213

- name: download erlang package

14get_url: url=} dest=/tmp/erlang.rpm

1516

- name: install erlang packages

17yum: name=/tmp/erlang.rpm state=present

1819

- name: download rabbitmq package

20get_url: url=} dest=/tmp/rabbitmq-server.rpm

2122

- name: rpm install rabbitmq-server

23yum: name=/tmp/rabbitmq-server.rpm state=present

2425

- name: start rabbitmq-server

26service: name=rabbitmq-server enabled=yes state=restarted

2728

- name: enable the plugins is installed

29shell: rabbitmq-plugins enable rabbitmq_management && rabbitmq-plugins enable rabbitmq_mqtt && rabbitmq-plugins enable rabbitmq_web_mqtt

30notify:

31restart rabbitmq-server

3233

- name: create the rabbitmq user

34shell: rabbitmqctl add_user } }

35ignore_errors: yes

3637

- name: add rabbitmq_user to adminstrator

38shell: rabbitmqctl set_user_tags } administrator

3940

- name: configure the rabbitmq_user premission

41shell: rabbitmqctl set_permissions -p "/" } ".*" ".*" ".*"

4243

- name: del rabbitmq install pkg

44file: path=} state=absent

45with_items:

46- /tmp/erlang.rpm

47- /tmp/rabbitmq-server.rpm

4849

handlers:

50- name: restart rabbitmq-server

51 service: name=rabbitmq-server state=restarted

view code

使用方法:

ansible-playbook rabbitmq_install.yml --extra-vars "

"

CentOS下安裝Erlang和RabbitMQ

首先使epel 生效 rpm uvh wget o etc yum.repos.d epel erlang.repo 安裝包 otp src r14b.tar.gz ok 了現在開始用 yum 安裝 erlang 和 rabbitmq吧 yum install erlang rabbitmq ser...

ansible自動化批量安裝nginx

ansible安裝及ssh免密登入請參考 ansible playbook 劇本 ansible doc 獲取幫助文件 ansible playbook採用yaml語法 核心元件 hosts 定義單個主機或組,vars定義變數,remote user定義執行命令的遠端使用者,tasks定義執行哪些命...

自動化運維Ansible安裝篇

ansible自動化工具之 部署篇 ansible是新出現的自動化運維工具,基於python開發,集合了眾多運維工具 puppet cfengine chef func fabric 的優點,實現了批量系統配置 批量程式部署 批量執行命令等功能。ansible是基於模組工作的,本身沒有批量部署的能力...