LoginSignup
0
0

More than 5 years have passed since last update.

ansibleで冪等性を保証しながらファイルが存在しない場合のみ空ファイルを作る

Last updated at Posted at 2017-03-24

単純にtouchすると、毎回touchされて鬱陶しかったので。

- name: Check iptables log file
  stat:
    path: /var/log/iptables/iptables.log
  register: iptables_log

- name: Create iptables log file
  file:
    path: /var/log/iptables/iptables.log
    state: touch
  when: iptables_log.stat.exists == false

- name: Set attribute for iptables log file
  file:
    path: /var/log/iptables/iptables.log
    owner: syslog
    group: syslog
    mode:  0600
0
0
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
0
0