Ansible Module file: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
=Examples=
=Examples=


=Create a Directory=
==Create Directories==
<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml'>
- name: create local storage mount point
- name: create volume directories
   file:
   file:
     path: "{{ item }}"
     path: "/mnt/ebs0/{{ item }}"
     state: directory
     state: directory
     owner: root
     owner: root
   with_items:
   with_items:
     - "/mnt/ebs0"
     - "local-pv0"
    - "local-pv1"
    - "local-pv2"
   when:
   when:
     - inventory_hostname in groups['kube-node']
     - inventory_hostname in groups['kube-node']
</syntaxhighlight>
</syntaxhighlight>

Revision as of 06:56, 12 December 2019

External

Internal

Overview

Manage file, directory and symlinks properties: create, set attributes, remove.

Examples

Create Directories

- name: create volume directories
  file:
    path: "/mnt/ebs0/{{ item }}"
    state: directory
    owner: root
  with_items:
    - "local-pv0"
    - "local-pv1"
    - "local-pv2"
  when:
    - inventory_hostname in groups['kube-node']