-name 处的 ansible playbook 错误

ansible playbook error at -name

嗨,我在 运行 以下 ansible-playbook 时出错: (我正在尝试在我的虚拟机上安装 LAMP 堆栈和 wordpress) 该错误似乎来自数据库。
mysql_db 和 mysql_user 是创建数据库和用户的有效命令吗?

请帮忙,谢谢。

---
- hosts: vbox
  remote_user: arnold
  become: yes
  become_method: sudo
  vars:
    MySQL_root_pass: root_pass
    dbase: dbwordpress
    user: wp_user
    parola: wp_pass
  tasks:
    - name: Linux update
      apt: update_cache=yes

    - name: Linux upgrade
      apt: upgrade=safe
      async: 600
      poll: 5

    - name: Install apache
      apt: pkg=apache2 state=installed
      notify:
       - start apache

    - name: Set MySQL root password before installing
      debconf: name='mysql-server' question='mysql-server/root_password' value='{{MySQL_root_pass | quote}}' vtype='password'

    - name: Confirm MySQL root password before installing
      debconf: name='mysql-server' question='mysql-server/root_password_again' value='{{MySQL_root_pass | quote}}' vtype='password'

    - name: Install mysql
      apt: name={{ item }} state=installed
      with_items:
       - mysql-server
       - libapache2-mod-auth-mysql
       - pkg=php5-mysql
      notify:
       - start mysql

    - name: Install php
      apt: name={{ item }} state=installed
      with_items:
       - php5
       - libapache2-mod-php5
       - php5-mcrypt
      notify:
       - restart apache

    - name: Create database and user for wordpress
      mysql_db: name={{ dbase }} state=present
      mysql_user: name={{ user }} password={{ parola }} priv=dbwordpress.*:ALL state=present
      notify:
       - restart mysql

    - name: Install wordpress
      command: "{{ item }}"
      with_items:
       - cd ~
       - wget http://wordpress.org/latest.tar.gz
       - tar xzvf latest.tar.gz
       - cd ~/wordpress
       - cp wp-config-sample.php wp-config.php
    - name: Config wordpress
      lineinfile: dest=~/wordpress/wp-config.php {{ item }}
      with_items:
       - regexp=^DB_NAME line="define('DB_NAME', '{{ dbase }}');"
       - regexp=^DB_USER line="define('DB_USER', '{{ user }}');"
       - regexp=^DB_PASSWORD line="define('DB_PASSWORD', '{{ parola }}');"

    - name: Copy files to root document
      command: "{{ item }}"
      with_items:
       - rsync -avP ~/wordpress/ /var/www/html/
       - cd /var/www/html
       - chown -R arnold:arnold *

  handlers:
    - name: start apache
      service: name=apache state=started
    - name: start mysql
      service: name=mysql state=started
    - name: restart mysql
      service: name=mysql state=restarted
    - name: restart apache
      service: name=php state=restarted

错误代码:

ERROR! conflicting action statements

The error appears to have been in '/home/arnold/Documents/wordpress':    line 49, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: Create database and user for wordpress
      ^ here


The error appears to have been in '/home/arnold/Documents/wordpress': line 49, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: Create database and user for wordpress
      ^ here

您在一项任务下有两个模块 mysql_dbmysql_user

- name: Create database and user for wordpress
   mysql_db: name={{ dbase }} state=present
   mysql_user: name={{ user }} password={{ parola }} priv=dbwordpress.*:ALL state=present
   notify:
       - restart mysql

将他们分成两个任务:

- name: Ensure the database for WordPress exists
  mysql_db: name={{ dbase }} state=present
  notify:
    - restart mysql

- name: Ensure the user for WordPress exists
  mysql_user: name={{ user }} password={{ parola }} priv=dbwordpress.*:ALL state=present
  notify:
   - restart mysql