Ansible Yum 模块无法正常工作

Ansible Yum Module is not working correctly

我正在创建一个 ansible 脚本来自动执行 LDAP 配置。但是,当我对脚本进行测试 运行 时,我总是得到:

ERROR: yum is not a legal parameter of an Ansible Play

我对使用 ansible 有点生疏,但我很确定我做对了(语法上):

---
#Kicks off the installation of Tomcat and MySQL
- name: Connecting to Anssible_centos
  hosts: ansible_centos
  remote_user: root

- name: Retreiving MySQL RPM and Installing
  yum: name=http://dev.sql.com/get/mysql157-community-release-e16-7.noarch.rpm state=present
- debug: var=outputmySql

- name: Disabling MySql57-Community
  yum: disablerepo=mysql57-community
- debug: var=outputDisable

- name: Enabling Mysql56-Community
  yum: enablerepo=mysql56-community
- debug: var=outputEnable

- name: Installing mySql 5.6
  yum: name="mysql-community-server" state=present
- debug: var=install56

- name: Starting MySql 5.6
  service: name=mysqld state=started
- debug: var=serviceStart

- name: Update MySql root password
  mysql_user: name=root host=127.0.0.1 password=codiscope
- debug: var=rootmysql

有什么想法吗?

您的语法实际上有点偏差。您的剧本应该更像这样:

- name: Connecting to Anssible_centos
  hosts: ansible_centos
  remote_user: root
  tasks:

   - name: Retreiving MySQL RPM and Installing
     yum: name=http://dev.sql.com/get/mysql157-community-release-e16-7.noarch.rpm state=present

如果您想查看每个任务的结果,那么您需要做一些类似于此的事情:

   - name: Retreiving MySQL RPM and Installing
     yum: name=http://dev.sql.com/get/mysql157-community-release-e16-7.noarch.rpm state=present
     register: outputmySql

   - debug: var=outputmySql