When I use ansible_host in lineinfile module with ansible 2.0, I get ansible_host="". But in debug module, I can get exact host name by ansible_host. Is it a ansible 2.0 bug? Actually, when I used ansible_ssh_host with ansible 1.9, it was OK.
My tasks are: - debug: msg="ansible_host is {{ ansible_host }}" - name: Configure SonarQube host, context and port. lineinfile: dest: /usr/local/sonar/conf/sonar.properties regexp: "{{ item.regexp }}" line: "{{ item.line }}" with_items: - regexp: "^sonar.web.host" line: "sonar.web.host={{ ansible_host }}" - regexp: "^sonar.web.port" line: "sonar.web.port={{ sonar_http_port }}" - regexp: "^sonar.web.context" line: "sonar.web.context={{ sonar_http_context }}" - regexp: "^sonar.search.port" line: "sonar.search.port=0" The tasks result is: TASK [sonar : debug] *********************************************************** ok: [controller] => { "msg": "ansible_host is 192.168.33.10" } TASK [sonar : Configure SonarQube host, context and port.] ********************* ok: [controller] => (item={u'regexp': u'^sonar.web.host', u'line': u' sonar.web.host='}) ok: [controller] => (item={u'regexp': u'^sonar.web.port', u'line': u'sonar.web.port=9000'}) ok: [controller] => (item={u'regexp': u'^sonar.web.context', u'line': u'sonar.web.context='}) ok: [controller] => (item={u'regexp': u'^sonar.search.port', u'line': u'sonar.search.port=0'}) -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c8a2e564-d762-405e-8f54-47e1b5811a75%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.