local_action is executed at the end and not in order its defined in.

8 views
Skip to first unread message

Sebastien Hadjifotis

unread,
Aug 21, 2015, 9:13:18 AM8/21/15
to Ansible Project
---
# file: cmservers.yml
- hosts: cmservers
  tasks:
     - include_vars: /var/cm/local/ansible/vault/cmservers
     - local_action: "command openssl passwd -salt '{{ cm_default_password_salt }}' -1 '{{ cm_default_password }}'"
       run_once: True
       register: password_hash
       changed_when: False
     - set_fact: users_default_password="{{ password_hash.stdout }}"
     - debug: var=password_hash
     - debug: var=users_default_password
     - debug: msg="Default hash is {{ users_default_password }}"
  roles:
   - ansible-users-master


TASK: [ansible-users-master | Create users] ***********************************
ok: [miluvl162] => (item={'comment': 'Some User', 'state': 'present', 'group': 'primgroup', 'name': 'user1', 'groups': ['extragroup'], 'is_admin': False, 'uid': 20001})

TASK: [ansible-users-master | Add admin users to admin group] *****************
skipping: [miluvl162] => (item={'comment': 'Some User', 'state': 'present', 'group': 'primgroup', 'name': 'user1', 'groups': ['extragroup'], 'is_admin': False, 'uid': 20001})

TASK: [ansible-users-master | Remove group] ***********************************
skipping: [miluvl162] => (item={'gid': 29999, 'name': 'primgroup'})
skipping: [miluvl162] => (item={'gid': 39999, 'name': 'extragroup'})

TASK: [ansible-users-master | Remove per-user groups] *************************
skipping: [miluvl162] => (item={'comment': 'Some User', 'state': 'present', 'group': 'primgroup', 'name': 'user1', 'groups': ['extragroup'], 'is_admin': False, 'uid': 20001})

TASK: [ansible-users-master | SSH keys] ***************************************
skipping: [miluvl162]

TASK: [ansible-users-master | Sudo installed] *********************************
ok: [miluvl162]

Why is the local_action being executed at the end? I need it at the start.
Any help appreciated.
Thanks

Brian Coca

unread,
Aug 21, 2015, 10:10:26 AM8/21/15
to Ansible Project
roles: executes before tasks:, put it in pre_tasks: which executes before roles:




--
Brian Coca
Reply all
Reply to author
Forward
0 new messages