manala.files

#######################################################################################################

:exclamation: DEPRECATION :exclamation:

This repository and the role associated are deprecated in favor of the Manala Ansible Collection

You will find informations on its usage on the collection repository

#######################################################################################################

Ansible Role: Files Build Status

:exclamation: Report issues and send Pull Requests in the main Ansible Role repository :exclamation:

This role will deal with the attributes of files.

It's part of the Manala Ansible stack but can be used as a stand alone component.

Requirements

None.

Dependencies

None.

Installation

Ansible 2+

Using ansible galaxy cli:

ansible-galaxy install manala.files

Using ansible galaxy requirements file:

- src: manala.files

Role Variables

Name Default Type Description
manala_files_attributes [] Array Files attributes
manala_files_attributes_defaults [] Array Files attributes defaults

Configuration example

General:

manala_files_attributes:
  # Ignore attribute
  - path: /tmp/foo
    state: ignore
  # Flatten attributes
  - "{{ my_custom_files_attributes_array }}"

File:

manala_files_attributes:
  - path: /tmp/foo # Required. An empty file is created on path if not present
  - path: /tmp/bar
    user: foo
    group: bar
    mode: "0644"
  - path: /tmp/baz
    state: absent
  - path: /tmp/qux
    parents: true # Recursively create file's directories
    force: true # Force path to be a file

Directory:

manala_files_attributes:
  - path: /tmp/foo # Required
    state: directory
  - path: /tmp/bar
    state: directory
    user: foo
    group: bar
    mode: "0755"
  - path: /tmp/baz
    state: absent
  - path: /tmp/qux
    state: directory
    force: true # Force path to be a directory

Link:

manala_files_attributes:
  - path: /tmp/foo # Required
    src: /tmp/bar
  - path: /tmp/qux
    src: /tmp/bar
    force: true # Force path to be a link

Template:

manala_files_attributes:
  - path: /tmp/foo # Required
    template: foo.j2
  - path: /tmp/bar
    template: foo.j2
    user: foo
    group: bar
    mode: "0755"
  - path: /tmp/baz
    template: foo.j2
    state: absent
  - path: /tmp/qux
    template: foo.j2
    parents: true # Recursively create template file's directories

Content:

manala_files_attributes:
  - path: /tmp/foo/bar # Required
    content: |
      Hello world!
  - path: /tmp/bar
    content: |
      Hello world!
    user: foo
    group: bar
    mode: "0755"
  - path: /tmp/baz
    content: |
      Hello world!
    state: absent
  - path: /tmp/qux
    content: |
      Hello world!
    parents: true # Recursively create content file's directories

Copy:

manala_files_attributes:
  - path: /tmp/foo # Required
    copy: /tmp/bar

Symbolic link to directory:

manala_files_attributes:
  - path: /path/to/link # Required
    src: /path/to/directory # Required
    state: link_directory
    #force: true # Force both `path` to be a link and `src` to be a directory
    #parents: true # Recursively create both link's directories

Symbolic link to file:

manala_files_attributes:
  - path: /path/to/link # Required
    src: /path/to/file # Required
    state: link_file
    #force: true # Force both `path` to be a link and `src` to be a file
    #parents: true # Recursively create both file and link's directories

Get url:

manala_files_attributes:
  - path: /tmp/bar # Required
    url: http://example.com/foo

Get url and unarchive:

manala_files_attributes:
  - path: /tmp/bar.tar.gz
    url: http://example.com/foo.tar.gz
    unarchive: true
    creates: /tmp/baz

Defaults:

manala_files_attributes_defaults:
  # Will be applied to *all* files attributes
  - user: nobody
    parents: true
  # Will be applied to files attributes path beginning by "/etc"
  - path: ^/etc
    user: root
    group: root

Example playbook

- hosts: all
  roles:
    - role: manala.files

Licence

MIT

Author information

Manala (http://www.manala.io/)

About

Handle files attributes

Install
ansible-galaxy install manala.files
GitHub repository
License
Unknown
Downloads
10.2k
Owner
Manala is an open source project supported by the french web agency ELAO providing advanced ansible roles for website's infrastructures and far more.