RUNDECK呼叫ANSIBLE執行日常的運維工作

2021-09-01 20:08:06 字數 910 閱讀 6754

系統平台:centos7

可實現多台機器批量掛載磁碟,避免手工操作的錯誤

ansible的playbook如下:

- name: addtorc.local    | 寫入啟動命令

lineinfile:

dest: "/etc/rc.local"

state: present

regexp: 'mount } }'

line: "mount } }"

backup: yes

- name: echo cmd_out      | df -h

shell: "df -h"

register: startup_out

- name: echo startup_out  | 列印啟動資訊

debug: var=startup_out

rundeck作業如下:

diskuncs

mountdir

summary

mounts

true

runjobs

ef4f173e-6f8f-4cfb-9495-77a371d7336d

info

mounts

false

true

ansible-playbook  /testmountbecome.yml --extra-vars "dsthosts=$ diskuncs=$ mountdir=$"

ef4f173e-6f8f-4cfb-9495-77a371d7336d

執行效果如圖:

事實上很多運維的相關工作都可以通過這種方式來完成,比如應用程式包的更新等等,實現的方式都是一樣的

ansibl 常用模組介紹

yum install epel release y yum install ansible yansible.cfg hosts roles ansible.cfg ansible 配置檔案 hosts 主機組的檔案 roles 定義角色的 需要配置ssh 免登陸 ssh copy id 10.3...

ansibl中動態清單的管理

在編寫使用者清單時,出現多台主機,有時為了方便管理的配置,可以使用萬用字元,對一類主機進行配置 萬用字元使用 所有主機均指清單中設定的主機 匹配所有主機 hosts 匹配網域名稱為example.com的所有主機 hosts example.com 匹配172.25.254.0網段多有主機 host...

使用rundeck排程工具設定傳送郵件

1.1開啟smtp服務,獲取授權碼 1.2選擇賬戶 如果 postfix start 失敗 root rzdatahadoop002 postfix check postfix error while loading shared libraries libmysqlclient.so.16 can...