安装 Drupal 时出现的 Ansible playbook 错误

安装 Drupal 时出现的 Ansible playbook 错误

请帮助解决以下剧本的错误。还有一些其他剧本,所有这些都用于设置 Drupal。

下面的剧本是该设置的一部分,但它会引发错误。

---
 - name: Clone Drupal
   git: >
     repo=http://git.drupal.org/project/drupal.git
     dest=/var/www/html/drupal/
     update=no
 - name: download the code from repository
   get_url url:http://ftp.drupal.org/files/projects/drupal-7.37.zip dest: /tmp
 - name: Create Dir
   command: mkdir -p /var/www/html/
 - name: Copy the code from repository
   unarchive: src=/tmp/drupal-7.37.zip dest=/var/www/html/ copy=no
 - name: Create settings.php
   command: cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php
 - name: services.yml
   template: src=services.yml.j2 dest=/var/www/html/drupal/sites/default/service.yml
 - name: Update permissions of settings.php
   file: path=/var/www/html/drupal/sites/default/settings.php mode=777

 - name: Update permissions of service.yml
   file: path=/var/www/html/drupal/sites/default/service.yml mode=777

 - name: Update permissions of files directory
   file: >
     path=/var/www/html/drupal/sites/default/files
     mode=777
     state=directory
     recurse=yes

错误如下图所示:

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/opt/playbooks/drupal_set/roles/drupal/tasks/main.yml': line 7, column 4, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

     update=no
 - name: download the code from repository
   ^ here

如果剧本中还有任何尚未显示的错误,请帮助纠正。

答案1

您缺少操作的冒号,这导致该操作根本不被视为操作,并且 Ansible 对此发出抱怨。

- name: download the code from repository
  get_url: url:http://ftp.drupal.org/files/projects/drupal-7.37.zip dest: /tmp
         ^

答案2

我不太喜欢“折叠块标量” 使用 格式化>和使用 语法设置参数key=value,并倾向于使用与手册中使用的语法相同的语法,在我看来,你绝对不应该在同一个剧本中混合使用它们。
但无论如何,你: 在后面漏了一个冒号get_url

 - name: Clone Drupal
   git: 
     repo: http://git.drupal.org/project/drupal.git
     dest: /var/www/html/drupal/
     update: no

 - name: download the code from repository
   get_url:
     url: http://ftp.drupal.org/files/projects/drupal-7.37.zip 
     dest: /tmp

答案3

我认为它解决了那个特定的剧本并引发了下面的其他错误:

failed: [10.42.0.42] (item=[u'php5', u'php5-pdo', u'php5-mysqlnd', u'php5-gd', u'php5-mbstring', u'httpd', u'git', u'libsemanage-python', u'libselinux-python']) => {"changed": false, "item": ["php5", "php5-pdo", "php5-mysqlnd", "php5-gd", "php5-mbstring", "httpd", "git", "libsemanage-python", "libselinux-python"], "msg": "No package matching 'php5' found available, installed or updated", "rc": 126, "results": ["No package matching 'php5' found available, installed or updated"]}

对于这个剧本:

---
- name: Install apache
  yum: pkg={{ item }} state=present
  with_items:
    - php5
    - php5-pdo
    - php5-mysqlnd
    - php5-gd
    - php5-mbstring
    - httpd
    - git
    - libsemanage-python
    - libselinux-python
- name: http service state
  service: 
    name: httpd 
    state: started 
    enabled: yes

相关内容