creating directories (mkdir -p)

78 views
Skip to first unread message

Bobby Billingsley

unread,
Nov 20, 2015, 2:51:54 PM11/20/15
to Ansible Project
I'm trying to create a subdirectory (to a not-necessarily existing directory) and failing utterly :-(

So far I've tried:

    - name: ensure config dir exists
      file: path={{base_dir}}/config state=directory mode=0755
      tags: myprog,confdir

base_dir is defined in the appropriate vars.yml:

base_dir: /home/my/base

both of which give me the following output:

    TASK: [ensure config dir exists] **********************
    changed: [host01]
    changed: [host02]


This leads me to believe that the dir should've been created.

However, the next task in the play:

    - name: ensure handy symlink exists
      file: src={{base_dir}} dest=/mybase state=link
      tags: myprog,rootlink


fails miserably:

    TASK: [ensure handy symlink exists] *******************
    failed: [host01] => {"failed": true, "path": "/mybase", "src": "/home/my/base", "state": "absent"}
    msg: src file does not exist, use "force=yes" if you really want to create the link: /home/my/base
    failed: [host02] => {"failed": true, "path": "/mybase", "src": "/home/my/base", "state": "absent"}
    msg: src file does not exist, use "force=yes" if you really want to create the link: /home/my/base


so i tried a different tack:

        - name: ensure config dir exists
          command: /bin/mkdir -p {{base_dir}}/config creates={{base_dir}}/config
          tags: myprog,confdir

which also fails to do what I was expecting.

Checking the /home directory on both destinations reveals that no intermediate directories were created.

I'm stumped - any suggestions?

/bobby

Reply all
Reply to author
Forward
0 new messages