title: ansible mount a remote nfs share to the localhost server running ansible playbook
body: <p>When running ansible.posix.mount, an ssh connection is created to the src, then the path directory is created on said server.
  I want to be able to just mount nfs share from a remote server locally on the box running the ansible playbook.</p>
  <p>I understand that the second task in my playbook below is performing said task on any hosts in my inventory under &quot;nfs-server&quot;, however I need to include that host as it is the destination ip variable I need to point the mount share at. I do not want to have to add IP address destinations to my settings.yml, would rather iterate via the inventory file if possible.</p>
  <p>What am I missing?</p>
  <p>Here is my playbook:</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: Create directory
    hosts: localhost
    gather_facts: False
  
    tasks:
      - name: Include vars
        include_vars:
            file: settings.yaml
            name: settings
  
      - name: Create local directory &quot;nfs-ansible&quot;
        file:
          path: ./nfs-ansible
          state: directory
        delegate_to: localhost
  
  - name: Mount nfs share to localhost
    hosts: nfs-server
    gather_facts: False
    become: yes
  
    tasks:
      - name: Include idrac vars
        include_vars:
            file: settings.yaml
            name: settings
  
      - name: Mount share from nfs-server
        ansible.posix.mount:
          src: &quot;{{ hostvars[inventory_hostname].ipaddress }}:/nfs-share&quot;
          path: ./nfs-ansible
          state: mounted
          fstype: nfs
  </code></pre>