Ansible win_file can not create a directory on a partitioned drive?

77 views
Skip to first unread message

zil...@gmail.com

unread,
Jun 21, 2021, 9:35:04 PM6/21/21
to Ansible Project
Ansible 2.11.0

I created an I: disk partition on my Windows 2019 host under jenkins user, who is an admin. Logged in as jenkins, I can create a directory on the partition through the GUI.

Now I have this Ansible task that simply tries to create the same directory structure, like this

  - name: "Create data directory {{ pg_data_dir }}"
    win_file:
      path: "{{ pg_data_dir }}" # I:\pgdata\13
      status: directory

I get ...

TASK [postgresql : Create data directory I:\pgdata\13] ********************************
task path: /path/ansible/exa-playbooks/roles/postgresql/tasks/install_postgresql.yml:21
redirecting (type: modules) ansible.builtin.win_file to ansible.windows.win_file
Using module file /usr/local/Cellar/ansible/3.3.0/libexec/lib/python3.9/site-packages/ansible_collections/ansible/windows/plugins/modules/win_file.ps1
Pipelining is enabled.
<10.227.xx.xx> ESTABLISH WINRM CONNECTION FOR USER: jenkins on PORT 5986 TO 10.227.xx.xx
EXEC (via pipeline wrapper)
fatal: [10.227.xx.xx]: FAILED! => {
    "changed": false,
    "msg": "path I:\\pgdata\\13 will not be created"
}

Any clues?

jbor...@gmail.com

unread,
Jun 22, 2021, 2:58:34 PM6/22/21
to Ansible Project
You have a typo, it's 'state' not 'status'. The default value is 'state: file' and due to historical behaviour 'state: file' will not create the file.

zil...@gmail.com

unread,
Jun 22, 2021, 7:46:03 PM6/22/21
to Ansible Project
Duh on me. Thanks!

Chris

Reply all
Reply to author
Forward
0 new messages