Ansible fileモジュールでファイルやディレクトリの権限を設定する方法
環境
Ansible
概要
1.ディレクトリの作成
path:ディレクトリ名
state:directory
2.ファイルの作成
path: ファイル名
state:touch
mode:755
使用例
---
- hosts: servers
tasks:
- name: ディレクトリ作成
ansible.builtin.file:
path: /home/ec2-user/tmp
state: directory
- name: 空白ファイルの作成
ansible.builtin.file:
path: /home/ec2-user/tmp/run.sh
state: touch
mode: 755
- name: shellリンク作成
ansible.builtin.file:
path: /home/ec2-user/tmp/s.sh
state: link
src: /home/ec2-user/tmp/run.sh
---
- hosts: servers
tasks:
- name: ディレクトリ作成
ansible.builtin.file:
path: /home/ec2-user/tmp
state: directory
- name: 空白ファイルの作成
ansible.builtin.file:
path: /home/ec2-user/tmp/run.sh
state: touch
mode: 755
- name: shellリンク作成
ansible.builtin.file:
path: /home/ec2-user/tmp/s.sh
state: link
src: /home/ec2-user/tmp/run.sh
--- - hosts: servers tasks: - name: ディレクトリ作成 ansible.builtin.file: path: /home/ec2-user/tmp state: directory - name: 空白ファイルの作成 ansible.builtin.file: path: /home/ec2-user/tmp/run.sh state: touch mode: 755 - name: shellリンク作成 ansible.builtin.file: path: /home/ec2-user/tmp/s.sh state: link src: /home/ec2-user/tmp/run.sh