【发布时间】:2020-07-06 17:39:30
【问题描述】:
在 Ansible playbook 中,我在运行启动服务模块时遇到错误,因为我想在远程主机上启动数据库。我是 Ansible 的新手。
我想出了这个:
- name: This starts the MySQL Database in the host
hosts: dbserver
connection: ssh
become: yes
become_method: sudo
tasks:
- name: Start the DB in host
become: yes
become_user: root
service:
name: mysql
state: started
我收到此错误:
致命:[10.138.12.67]:失败! => {"changed": false, "msg": "找不到请求的服务mysql:host"}
【问题讨论】:
-
mysql 服务器的服务通常以 mysqld 的名称而闻名(对于 daemon)。还有一个简单的说明:如果
become_*选项已经在播放级别设置,则无需在任务级别设置它们。
标签: ansible