<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">lineinfile</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">2.4.2</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">I was trying to take control of a brand new Debian 8.3 machine (AWS, Debian official AMI) via ansible. The default user is <code class="notranslate">admin</code>, the ssh key is present but it seems that is impossible to get root access on this machine without manual intervention which really sucks as is against automation and auto-provisioning.</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: neon
  tasks:
    - name: Remove require tty
      lineinfile: regexp=&quot;^\s+\w+\s+requiretty&quot; dest=/etc/sudoers state=absent
      become_method: sudo
      become_user: root
      become: yes"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">neon</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">Remove require tty</span>
      <span class="pl-ent">lineinfile</span>: <span class="pl-s">regexp="^\s+\w+\s+requiretty" dest=/etc/sudoers state=absent</span>
      <span class="pl-ent">become_method</span>: <span class="pl-s">sudo</span>
      <span class="pl-ent">become_user</span>: <span class="pl-s">root</span>
      <span class="pl-ent">become</span>: <span class="pl-s">yes</span></pre></div>
<p dir="auto">I tried all become methods, no luck.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="IOError: [Errno 13] Permission denied: '/etc/sudoers`"><pre class="notranslate"><code class="notranslate">IOError: [Errno 13] Permission denied: '/etc/sudoers`
</code></pre></div>
<h5 dir="auto">Issue Type:</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">Ansible Version:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible --version
ansible 2.0.0 (devel efcad3aa6d) last updated 2015/07/30 15:16:07 (GMT -200)
  lib/ansible/modules/core: (detached HEAD ff69ce7912) last updated 2015/07/07 11:42:48 (GMT -200)
  lib/ansible/modules/extras: (detached HEAD 4e48ef9eca) last updated 2015/07/07 11:43:20 (GMT -200)
  v1/ansible/modules/core: (detached HEAD f8d8af17cd) last updated 2015/07/07 11:43:45 (GMT -200)
  v1/ansible/modules/extras: (detached HEAD 495ad450e5) last updated 2015/07/07 11:44:04 (GMT -200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = None"><pre class="notranslate"><code class="notranslate">$ ansible --version
ansible 2.0.0 (devel efcad3aa6d) last updated 2015/07/30 15:16:07 (GMT -200)
  lib/ansible/modules/core: (detached HEAD ff69ce7912) last updated 2015/07/07 11:42:48 (GMT -200)
  lib/ansible/modules/extras: (detached HEAD 4e48ef9eca) last updated 2015/07/07 11:43:20 (GMT -200)
  v1/ansible/modules/core: (detached HEAD f8d8af17cd) last updated 2015/07/07 11:43:45 (GMT -200)
  v1/ansible/modules/extras: (detached HEAD 495ad450e5) last updated 2015/07/07 11:44:04 (GMT -200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = None
</code></pre></div>
<h5 dir="auto">Ansible Configuration:</h5>
<p dir="auto">The /etc/ansible/ansible.cfg is exactly the same as the version on github.</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Ubuntu 14.04 LTS</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Ansible won't work when VagrantFile is at the same level as ansible dir.<br>
The base ansible path is duplicated.<br>
It works though if the Vagrant file is inside a folder, and this folder in turn is at the same level as ansible dir.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Create a structure like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=".
├── ansible
│   ├── group_vars
│   │   └── all
│   └── site.yml
├── directory
│   └── Vagrantfile
└── Vagrantfile"><pre class="notranslate"><code class="notranslate">.
├── ansible
│   ├── group_vars
│   │   └── all
│   └── site.yml
├── directory
│   └── Vagrantfile
└── Vagrantfile
</code></pre></div>
<p dir="auto">Where <code class="notranslate">ansible/group_vars/all</code> is empty; <code class="notranslate">ansible/site.yml</code> is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- hosts: all
  tasks:
      - name: Test
          assert:
              that:
                  - 1 == 1"><pre class="notranslate"><code class="notranslate">
---
- hosts: all
  tasks:
      - name: Test
          assert:
              that:
                  - 1 == 1
</code></pre></div>
<p dir="auto"><code class="notranslate">VagrantFile</code> is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Vagrant.configure(2) do |config|

  config.vm.box = &quot;ubuntu/trusty64&quot;
  config.vm.provision &quot;ansible&quot; do |ansible|
    ansible.playbook = &quot;ansible/site.yml&quot;
    ansible.host_key_checking = false
    ansible.verbose = &quot;v&quot;
  end
end"><pre class="notranslate"><code class="notranslate">Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "ansible/site.yml"
    ansible.host_key_checking = false
    ansible.verbose = "v"
  end
end
</code></pre></div>
<p dir="auto">And <code class="notranslate">directory/VagrantFile</code> is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Vagrant.configure(2) do |config|

  config.vm.box = &quot;ubuntu/trusty64&quot;
  config.vm.provision &quot;ansible&quot; do |ansible|
    ansible.playbook = &quot;../ansible/site.yml&quot;
    ansible.host_key_checking = false
    ansible.verbose = &quot;v&quot;
  end
end"><pre class="notranslate"><code class="notranslate">Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "../ansible/site.yml"
    ansible.host_key_checking = false
    ansible.verbose = "v"
  end
end
</code></pre></div>
<ol dir="auto">
<li>Run <code class="notranslate">vagrant up</code> from the base dir.</li>
<li>Run from the same dir: <code class="notranslate">ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key --inventory-file=.vagrant/provisioners/ansible/inventory ansible/site.yml</code></li>
</ol>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">The playbook to run sucessfully.</p>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key --inventory-file=.vagrant/provisioners/ansible/inventory ansible/site.yml
ERROR! the file_name '/home/alfeto/work/ansible_bug/ansible/ansible/group_vars/all' does not exist, or is not readable"><pre class="notranslate"><code class="notranslate">$ ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key --inventory-file=.vagrant/provisioners/ansible/inventory ansible/site.yml
ERROR! the file_name '/home/alfeto/work/ansible_bug/ansible/ansible/group_vars/all' does not exist, or is not readable
</code></pre></div>
<p dir="auto">Notice how <code class="notranslate">ansible</code> appears twice: <code class="notranslate">/home/alfeto/work/ansible_bug/ansible/ansible/group_vars/all</code></p>
<h5 dir="auto">Extra info:</h5>
<p dir="auto">If <code class="notranslate">ansible-playbook</code> is run instead from <code class="notranslate">directory/</code>, the playbook runs successfully:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/directory$ ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key --inventory-file=.vagrant/provisioners/ansible/inventory ../ansible/site.yml

PLAY ****************************************************************************

..."><pre class="notranslate"><code class="notranslate">/directory$ ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key --inventory-file=.vagrant/provisioners/ansible/inventory ../ansible/site.yml

PLAY ****************************************************************************

...
</code></pre></div>