Ansible Playbook syntax check issue

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
-1
down vote

favorite












i have below detail in /etc/ansible/hosts



[dev] 10.13.212.32


and i am able ping this hosts as below:



# ansible dev -m ping


Output:



[root@localhost ~]# ansible dev -m ping
10.13.212.32 | SUCCESS => {
"changed": false,
"ping": "pong"


when i check syntax of *.yml file .



# ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


or



# ansible-playbook nginx.yml --check**
[WARNING]: Unable to parse /root/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator


The error appears to have been in '/root/nginx.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.



The offending line appears to be:



- name: install and start nginx
hosts: localhost
^ here


help me out with the issue.







share|improve this question





















  • can u check the host declaration?
    – SivaPrasath
    Aug 3 at 10:50
















up vote
-1
down vote

favorite












i have below detail in /etc/ansible/hosts



[dev] 10.13.212.32


and i am able ping this hosts as below:



# ansible dev -m ping


Output:



[root@localhost ~]# ansible dev -m ping
10.13.212.32 | SUCCESS => {
"changed": false,
"ping": "pong"


when i check syntax of *.yml file .



# ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


or



# ansible-playbook nginx.yml --check**
[WARNING]: Unable to parse /root/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator


The error appears to have been in '/root/nginx.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.



The offending line appears to be:



- name: install and start nginx
hosts: localhost
^ here


help me out with the issue.







share|improve this question





















  • can u check the host declaration?
    – SivaPrasath
    Aug 3 at 10:50












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











i have below detail in /etc/ansible/hosts



[dev] 10.13.212.32


and i am able ping this hosts as below:



# ansible dev -m ping


Output:



[root@localhost ~]# ansible dev -m ping
10.13.212.32 | SUCCESS => {
"changed": false,
"ping": "pong"


when i check syntax of *.yml file .



# ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


or



# ansible-playbook nginx.yml --check**
[WARNING]: Unable to parse /root/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator


The error appears to have been in '/root/nginx.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.



The offending line appears to be:



- name: install and start nginx
hosts: localhost
^ here


help me out with the issue.







share|improve this question













i have below detail in /etc/ansible/hosts



[dev] 10.13.212.32


and i am able ping this hosts as below:



# ansible dev -m ping


Output:



[root@localhost ~]# ansible dev -m ping
10.13.212.32 | SUCCESS => {
"changed": false,
"ping": "pong"


when i check syntax of *.yml file .



# ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


or



# ansible-playbook nginx.yml --check**
[WARNING]: Unable to parse /root/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator


The error appears to have been in '/root/nginx.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.



The offending line appears to be:



- name: install and start nginx
hosts: localhost
^ here


help me out with the issue.









share|improve this question












share|improve this question




share|improve this question








edited Aug 3 at 10:48









SivaPrasath

3,27511333




3,27511333









asked Aug 3 at 10:40









Govinda Chaulagain

1914




1914











  • can u check the host declaration?
    – SivaPrasath
    Aug 3 at 10:50
















  • can u check the host declaration?
    – SivaPrasath
    Aug 3 at 10:50















can u check the host declaration?
– SivaPrasath
Aug 3 at 10:50




can u check the host declaration?
– SivaPrasath
Aug 3 at 10:50










1 Answer
1






active

oldest

votes

















up vote
0
down vote













The error is exactly what is says, there is no /root/hosts file!



ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


With the -i switch (--inventory-file), you are pointing to the file /root/hosts (since you are running as root, from root's $HOME) instead of the file:



/etc/ansible/hosts


So, try again with:



ansible-playbook --syntax-check --list-tasks -i /etc/ansible/hosts ./nginx.yml


And your playbook fails due to incorrect syntax and indentation. Check this example for starters.






share|improve this answer























    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f460295%2fansible-playbook-syntax-check-issue%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    The error is exactly what is says, there is no /root/hosts file!



    ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


    With the -i switch (--inventory-file), you are pointing to the file /root/hosts (since you are running as root, from root's $HOME) instead of the file:



    /etc/ansible/hosts


    So, try again with:



    ansible-playbook --syntax-check --list-tasks -i /etc/ansible/hosts ./nginx.yml


    And your playbook fails due to incorrect syntax and indentation. Check this example for starters.






    share|improve this answer



























      up vote
      0
      down vote













      The error is exactly what is says, there is no /root/hosts file!



      ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


      With the -i switch (--inventory-file), you are pointing to the file /root/hosts (since you are running as root, from root's $HOME) instead of the file:



      /etc/ansible/hosts


      So, try again with:



      ansible-playbook --syntax-check --list-tasks -i /etc/ansible/hosts ./nginx.yml


      And your playbook fails due to incorrect syntax and indentation. Check this example for starters.






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        The error is exactly what is says, there is no /root/hosts file!



        ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


        With the -i switch (--inventory-file), you are pointing to the file /root/hosts (since you are running as root, from root's $HOME) instead of the file:



        /etc/ansible/hosts


        So, try again with:



        ansible-playbook --syntax-check --list-tasks -i /etc/ansible/hosts ./nginx.yml


        And your playbook fails due to incorrect syntax and indentation. Check this example for starters.






        share|improve this answer















        The error is exactly what is says, there is no /root/hosts file!



        ansible-playbook --syntax-check --list-tasks -i hosts ./nginx.yml


        With the -i switch (--inventory-file), you are pointing to the file /root/hosts (since you are running as root, from root's $HOME) instead of the file:



        /etc/ansible/hosts


        So, try again with:



        ansible-playbook --syntax-check --list-tasks -i /etc/ansible/hosts ./nginx.yml


        And your playbook fails due to incorrect syntax and indentation. Check this example for starters.







        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Aug 3 at 11:25


























        answered Aug 3 at 11:12









        maulinglawns

        4,9081821




        4,9081821






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f460295%2fansible-playbook-syntax-check-issue%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Christian Cage

            How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?