LoginSignup
1
1

More than 5 years have passed since last update.

Ansible 色々

Last updated at Posted at 2018-02-13

日付付きディレクトリ

元ネタ: 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
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1