Hi Shivharsh,
I tested the YAML syntax online it is showing correct.Kindly suggest the 
way to correct it
here is YAML 
---
# tasks file for ac.install
- name: make a new directory for downloading the installer
  shell: mkdir -p /installer/NAM
  #shell: cd /installer/NAM
  #register: make_directory
- name: Download File From FTP
    get_url:
    url: 
ftp://admin:[email protected]:22/home/admin/TestFtp/AM_431_AccessManagerService_Linux64.tar.gz
 
dest:/installer/NAM/AM_431_AccessManagerService_Linux64.tar.gz
- args: 
    chdir: /installer/NAM/

*Error:-*
ansible-playbook 2.8.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-4)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass it's 
verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass it's 
verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass it's 
verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to be in 
'/tmp/auto_install/ansible_install_script/roles/ac.install/tasks/main.yml': 
line 8, column 12, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Download File From FTP
    get_url:
           ^ here




On Thursday, September 12, 2019 at 3:19:50 PM UTC+5:30, Shivharsh Singh 
wrote:
>
> Hi Naeem,
>
> The Syntax error thrown is due to incorrect indentation in below block of 
> code. 
>
>  - name: Download File From FTP
>>      get_url:
>>      url: 
>> ftp://admin:[email protected]:22/home/admin/TestFtp/AM_431_AccessManagerService_Linux64.tar.gz
>>  dest:/installer/NAM/AM_431_AccessManagerService_Linux64.tar.gz
>
>
> Every "-" in YAML starts a new element and all the elements must be 
> equally indented. In your YAML, there is an extra indent before "- name: 
> Download File From FTP".
> Also, the "url" key of get_url module should be further indented to 
> reflect correct mapping. This is why the "mapping values are not allowed in 
> this context" error message was shown.
>
> So the correct YAML code would be as shown below:
>
> ---
> - hosts: localhost
>   tasks:
>       - name: make a new directory for downloading the installer
>         shell: mkdir -p /installer/NAM
>       - name: Download File From FTP
>         get_url:
>            url: ftp://
> admin:[email protected]:22/home/admin/TestFtp/AM_431_AccessManagerService_Linux64.tar.gz
>            dest: installer/NAM/AM_431_AccessManagerService_Linux64.tar.gz
>
>       - name: untar the downloaded builds
>         shell: cd /installer/NAM
>         shell: tar -zxvf AM_431_AccessManagerService_Linux64.tar.gz
>         args:
>            chdir: /installer/NAM/
>
>       - name: removing the installer tar file
>         shell: rm -r /installer/NAM/AM_431_AccessManagerService_Linux64.
> tar.gz
>
>       - shell: sudo ls -d /installer/NAM/AM_431_AccessManagerService*
>
>       - name: run the install script
>         shell: sudo printf 
> "Y\n1\n\n\n\n\n\n\n\nY\nY\nY\n\nadmin\ninovell\nnovell\n" | ./install.sh
>         args:
>            chdir: "{{ dir_name.stdout }}"
>
>       - debug:
>            var: run_installation
>
> Hope this is helpful !
>
> Thanks,
> Shivharsh
>  
> On Wednesday, 11 September 2019 15:08:54 UTC+5:30, Naeem Khan wrote:
>>
>> Hi Everyone,
>> I am facing issue in executing roles using some shell script.
>> the task is
>> 1. create one directory on remote host /installer/NAM
>> 2. copy the installable from ftp (ip:172.19.54.10 username:-admin 
>> password abc123 ).
>> 3. copy the installable  at  /installer/NAM
>> 4. untar the installable 
>> 5. remove the installable file
>> 6.execute the install.sh
>> below is the YAML please let me what is wrong in it i am unable to 
>> download file and subsequent steps.
>> Kindly reply ASAP or if some one have any sample YAML to download from 
>> FTP please share with me.
>>
>> --YAML Begin--
>> ---
>> # tasks file for ac.install
>> - name: make a new directory for downloading the installer
>>   shell: mkdir -p /installer/NAM
>>   #shell: cd /installer/NAM
>>   #register: make_directory
>>  - name: Download File From FTP
>>      get_url:
>>      url: 
>> ftp://admin:[email protected]:22/home/admin/TestFtp/AM_431_AccessManagerService_Linux64.tar.gz
>>  
>> dest:/installer/NAM/AM_431_AccessManagerService_Linux64.tar.gz
>>  - args:
>>      #chdir: /installer/NAM/
>>
>>  #register: download_installer
>>
>> - name: untar the downloaded builds
>>   shell: cd /installer/NAM
>>   shell: tar -zxvf AM_431_AccessManagerService_Linux64.tar.gz
>>   args:
>>      chdir: /installer/NAM/
>>   #register: extract_installer
>>
>> - name: removing the installer tar file
>>   shell: rm -r /installer/NAM/AM_431_AccessManagerService_Linux64.tar.gz
>>
>> - shell: sudo ls -d /installer/NAM/AM_431_AccessManagerService*
>>   #register: dir_name
>>
>> - name: run the install script
>>   shell: sudo printf 
>> "Y\n1\n\n\n\n\n\n\n\nY\nY\nY\n\nadmin\ninovell\nnovell\n" | ./install.sh
>>   args:
>>     chdir: "{{ dir_name.stdout }}"
>>   #register: run_installation
>>
>> - debug:
>>     var: run_installation
>>
>> ---YAML End---
>>
>> Error is as follows:--
>>
>> ansible-playbook 2.8.4
>>   config file = /etc/ansible/ansible.cfg
>>   configured module search path = [u'/root/.ansible/plugins/modules', 
>> u'/usr/share/ansible/plugins/modules']
>>   ansible python module location = 
>> /usr/lib/python2.7/site-packages/ansible
>>   executable location = /usr/bin/ansible-playbook
>>   python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 
>> 20150623 (Red Hat 4.8.5-4)]
>> Using /etc/ansible/ansible.cfg as config file
>> setting up inventory plugins
>> host_list declined parsing /etc/ansible/hosts as it did not pass it's 
>> verify_file() method
>> script declined parsing /etc/ansible/hosts as it did not pass it's 
>> verify_file() method
>> auto declined parsing /etc/ansible/hosts as it did not pass it's 
>> verify_file() method
>> Parsed /etc/ansible/hosts inventory source with ini plugin
>> ERROR! Syntax Error while loading YAML.
>>   mapping values are not allowed in this context
>>
>> The error appears to be in 
>> '/tmp/auto_install/ansible_install_script/roles/ac.install/tasks/main.yml': 
>> line 8, column 12, but may
>> be elsewhere in the file depending on the exact syntax problem.
>>
>> The offending line appears to be:
>>
>> - name: Download File From FTP
>>     get_url:
>>            ^ here
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9a9f359f-90a1-4626-8395-1579b90269de%40googlegroups.com.

Reply via email to