0

Please help in resolving the errors for the below playbook. There are few other playbooks and all that's for setting up Drupal.

The below playbook is part of that setup which is throwing error.

---
 - 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

The errors are as shown below:

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

Please help in correcting the playbook with any other errors if any which are not displayed yet.

JonathanDavidArndt
  • 1,424
  • 3
  • 20
  • 29
  • Use the `file:` module to create directories. The `command` module is not idempotent and will throw errors if the directory exists. Also use it for `copy`. If you change the `key=value` into `key: value`, and put one on each line, indented below the task, you, and more importantly, those who are trying to help you, can visually detect blocks quickly, easily, and accurately. Bottom line, Ansible docs are written with `key: value` syntax, and using another yml syntax, while technically valid, causes others to have to repeatedly translate and evaluate whether the alternate syntax is valid. – Jeter-work Apr 05 '18 at 17:06

3 Answers3

2

You are missing the colon for the action, which results in this not considered an action at all and Ansible complaining about it.

- name: download the code from repository
  get_url: url:http://ftp.drupal.org/files/projects/drupal-7.37.zip dest: /tmp
         ^
Sven
  • 98,649
  • 14
  • 180
  • 226
2

I'm not really a fan of the “Folded Block Scalar” formatting with the > and setting parameters with key=value syntax and prefer to use a syntax identical to what is used in the manual and you definitely shouldn't mix them in the same playbook IMHO.
But regardless you missed a colon : after 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
HBruijn
  • 77,029
  • 24
  • 135
  • 201
0

I think it resolved that particular playbook and throwing other errors as below:

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"]}

for this playbook:

---
- 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
Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43
  • You've posted a new question as an answer... SE is a Q&A site, not a forum. You should format this as a new question, and include troubleshooting steps. – Jeter-work Apr 05 '18 at 16:53
  • I reformatted your quoted code by inserting 4 spaces in front of each line, this creates a more readable code block. – Jeter-work Apr 05 '18 at 16:55
  • Also, I reformatted the `http service state` task. – Jeter-work Apr 05 '18 at 16:55
  • Finally, in general, when dealing with services, you should create a handler and trigger it in the `Install apache` task, so that it only acts when it needs to. In this instance, it's ok because you want the service `httpd` on all the time, but if there's any conditional, or if you're using `state: restarted`, you don't want to invoke unless it is needed. – Jeter-work Apr 05 '18 at 16:58