<p>I have a playbook and only want to run this play on the first master node. I tried moving the list into the role but did not see to work. Thanks for your help!</p>
<pre><code>## master node only changes
- name: Deploy change kubernetes Master
  remote_user: tyboard
  become: true
  roles:
  - role: gd.kubernetes.master.role
    files_location: ../files
  delegate_to: &quot;{{ groups['masters'][0] }}&quot; 
</code></pre>
<p>ERROR! 'delegate_to' is not a valid attribute for a Play</p>
<p>The error appears to be in '/mnt/win/kubernetes.playbook/deploy-kubernetes.yml': line 11, column 3, but may
be elsewhere in the file depending on the exact syntax problem.</p>
<p>The offending line appears to be:</p>
<h2>master node only changes</h2>
<ul>
<li>name: Deploy change kubernetes Master
^ here</li>
</ul>

TyBoard
<p>In one playbook, <a href="https://docs.ansible.com/ansible/latest/modules/add_host_module.html#add-host-add-a-host-and-alternatively-a-group-to-the-ansible-playbook-in-memory-inventory" rel="nofollow noreferrer">create a new group</a> with this host in the first play and use it in the second play. For example,</p>
<pre class="lang-yaml prettyprint-override"><code>shell&gt; cat playbook.yml
- name: Create group with masters.0
  host: localhost
  gather_facts: false
  tasks:
    - add_host:
        name: &quot;{{ groups.masters.0 }}&quot;
        groups: k8s_master_0

- name: Deploy change kubernetes Master
  hosts: k8s_master_0
  remote_user: tyboard
  become: true
  roles:
    - role: gd.kubernetes.master.role
      files_location: ../files
</code></pre>
<p><sup>(not tested)</sup></p>
<hr>
<ul>
<li><p>Fix the <a href="https://galaxy.ansible.com/docs/contributing/creating_role.html#role-names" rel="nofollow noreferrer">role name</a></p>
</li>
<li><p>If <code>files_location</code> is a variable which shall be used in the role's scope put it into the <code>vars</code>. For example</p>
</li>
</ul>
<pre class="lang-yaml prettyprint-override"><code>  roles:
    - role: gd.kubernetes.master.role
      vars:
        files_location: ../files
</code></pre>
