日付付きディレクトリ

元ネタ: https://teratail.com/questions/25330

vars:
  dir: "/tmp/base_{{ lookup('pipe','date +%Y%m%d%H%M') }}"

ディレクトリ作成

元ネタ: https://qiita.com/hnakamur/items/b5a17d8cb289432014d5

file: path="{{ base_dir }}" state=directory

state=directory がキモ

ディレクトリ削除

file: path="{{ base_dir }}" state=absent

state=absent がキモ

一時ディレクトリ作成

元ネタ: https://awsbloglink.wordpress.com/2017/01/24/ansible-2-3-%E6%96%B0%E6%A9%9F%E8%83%BD-tempfile-%E6%A4%9C%E8%A8%BC/

- hosts: all
  tasks:
    - name: create tmpdir
      tempfile:
        prefix: ppp
        state: directory
      register: tmpdir
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.