title: Ansible launch ssh-copy-id before running play?
body: <p>I want to use Ansible to disable selinux in some remote servers. I don't know yet the full list of the servers, it will come from time to time.</p>
  
  <p>That would be great if the <code>ssh-copy-id</code> phase would be integrated somehow in the playbook - you would expect that from an automation system ? I don't mind getting asked for the password one time per server.</p>
  
  <p>With various reading, I understand I can run a <code>local_action</code> in my task:</p>
  
  <pre><code>---
    - name: Disable SELinux
      hosts: all
      remote_user: root
      gather_facts: False
      tasks:
      - local_action: command ssh-copy-id {{remote_user}}@{{hostname}}
      - selinux:
          state: disabled
  </code></pre>
  
  <p>However:</p>
  
  <ul>
  <li>It fails because <code>{{remote_user}}</code> and <code>{{hostname}}</code> are not accessible in this context.</li>
  <li>I need to <code>gather_facts</code>to <code>False</code>, because it's executed before <code>local_action</code></li>
  </ul>
  
  <p>Any idea if that's possible within Ansible playbooks ?</p>