Showing Syntax error in a module

213 views
Skip to first unread message

nexio....@gmail.com

unread,
Mar 2, 2017, 8:02:54 AM3/2/17
to Ansible Project
Hello, I am trying to deploying wordpress using Ansible for first time. I installed LAMP on my remote server using Ansible but there was a syntax error while I was trying to install wordpress. it shows--

The error appears to have been in '/home/nxadmin/wordpress-ansible/roles/wordpress/tasks/main.yml': line 2, column 36, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: Download WordPress  get_url:
                                   ^ here

My script for deploying Word Press in roles/wordpress/tasks/main.yml are-

---
- name: Download WordPress  get_url:
    dest=/tmp/wordpress.tar.gz
    validate_certs=no

- name: Extract WordPress  unarchive= src=/tmp/wordpress.tar.gz dest=/var/www/ copy=no
  sudo: yes

- name: Update default Apache site
  sudo: yes
  lineinfile:
    dest=/etc/apache2/sites-enabled/000-default.conf
    regexp="(.)+DocumentRoot /var/www/html"
    line="DocumentRoot /var/www/wordpress"
  notify:
    - restart apache

- name: Copy sample config file
  command: mv /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php creates=/var/www/wordpress/wp-config.php
  sudo: yes

- name: Update WordPress config file
  lineinfile:
    dest=/var/www/wordpress/wp-config.php
    regexp="{{ item.regexp }}"
    line="{{ item.line }}"
  with_items:
    - {'regexp': "define\\('DB_NAME', '(.)+'\\);", 'line': "define('DB_NAME', '{{wp_mysql_db}}');"}
    - {'regexp': "define\\('DB_USER', '(.)+'\\);", 'line': "define('DB_USER', '{{wp_mysql_user}}');"}
    - {'regexp': "define\\('DB_PASSWORD', '(.)+'\\);", 'line': "define('DB_PASSWORD', '{{wp_mysql_password}}');"}
  sudo: yes


Pleae help, It would be thankful

Kai Stian Olstad

unread,
Mar 2, 2017, 11:49:20 AM3/2/17
to ansible...@googlegroups.com
On 02. mars 2017 08:47, nexio....@gmail.com wrote:
> Hello, I am trying to deploying wordpress using Ansible for first time. I
> installed LAMP on my remote server using Ansible but there was a syntax
> error while I was trying to install wordpress. it shows--
>
> The error appears to have been in
> '/home/nxadmin/wordpress-ansible/roles/wordpress/tasks/main.yml': line 2,
> column 36, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
> ---
> - name: Download WordPress get_url:
> ^ here
>
> My script for deploying Word Press in roles/wordpress/tasks/main.yml are-
>
> ---
> - name: Download WordPress get_url:
> url=https://wordpress.org/latest.tar.gz
> dest=/tmp/wordpress.tar.gz
> validate_certs=no

The module name, get_url, must be on the next line, and not on the same
line as - name:.
- name: Download WordPress
get_url:
url=https://wordpress.org/latest.tar.gz
dest=/tmp/wordpress.tar.gz
validate_certs=no


> - name: Extract WordPress unarchive= src=/tmp/wordpress.tar.gz
> dest=/var/www/ copy=no
> sudo: yes

The same goes for this one, unarchive: must be on the next line.
And you need to use a colon and not a equal sign after the module name.

--
Kai Stian Olstad

nexio....@gmail.com

unread,
Mar 3, 2017, 12:13:00 AM3/3/17
to Ansible Project
Thank you for helping me I tried that solution but now it is showing syntax error on different module

The offending line appears to be:


- name: Update default Apache site
^ here

Can you please check the whole script and tell me all the mistakes I have been done in this. It would be very thankful

Thank you 

Kai Stian Olstad

unread,
Mar 3, 2017, 3:08:37 AM3/3/17
to ansible...@googlegroups.com
I did an corrected them all except for sudo: that should be become:, but
sudo will work, you just get a deprecation message.
You have probably introduced new ones, so without the new code it's
difficult to see what's wrong now.
But your code should look like this now.

---
- name: Download WordPress
get_url:
url=https://wordpress.org/latest.tar.gz
dest=/tmp/wordpress.tar.gz
validate_certs=no

- name: Extract WordPress
unarchive:
src=skins/larry/tmp/wordpress.tar.gz
dest=/var/www/
copy=no
become: yes

- name: Update default Apache site
become: yes
lineinfile:
dest=/etc/apache2/sites-enabled/000-default.conf
regexp="(.)+DocumentRoot /var/www/html"
line="DocumentRoot /var/www/wordpress"
notify:
- restart apache

- name: Copy sample config file
command: mv /var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-config.php
creates=/var/www/wordpress/wp-config.php
become: yes

- name: Update WordPress config file
lineinfile:
dest=/var/www/wordpress/wp-config.php
regexp="{{ item.regexp }}"
line="{{ item.line }}"
with_items:
- {'regexp': "define\\('DB_NAME', '(.)+'\\);", 'line':
"define('DB_NAME', '{{wp_mysql_db}}');"}
- {'regexp': "define\\('DB_USER', '(.)+'\\);", 'line':
"define('DB_USER', '{{wp_mysql_user}}');"}
- {'regexp': "define\\('DB_PASSWORD', '(.)+'\\);", 'line':
"define('DB_PASSWORD', '{{wp_mysql_password}}');"}
become: yes


--
Kai Stian Olstad

nexio....@gmail.com

unread,
Mar 3, 2017, 4:01:41 AM3/3/17
to Ansible Project
It is working now. Thank you very much for helping me. :)
Reply all
Reply to author
Forward
0 new messages