DEV Community

Roy
Roy

Posted on

a wrong indent in yaml make comment invalid

  - name: set name resolve                                                                                                                                                                                         
    blockinfile:                                                                                                                                                                                                   
      path: /etc/hosts                                                                                                                                                                                             
      block: |                                                                                                                                                                                                     
        {{ hostvars[master-1]['ansible_facts']['eth1']['ipv4']['address'] }} cluster-endpoint                                                                                                                      
        #loop: "{{ groups['master'] }}"  

ansible gets an error says

The task includes an option with an undefined variable. The error was: 'master' is undefined

the line with # indented wrong, so the # cannot comment on the line, it is treated as a directive

it seems though the indent is wrong, the real problem is I should quote the hostname master-1

Top comments (0)