Create Directories and Update Files with Ansible or AAP

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/03 at 12:36 PM

 

Category:
Linux
RH AAP

Task:
Create a folder path using Ansible.

Notes:
- The the file module is part of ansible.builtin / ansible-core
- The mode can be set with '0660' or 'u+rw,g+rw,o-rwx'


Examples:
Code Snippet 1:
- name: Change file ownership after copying file from default 0664 to 0660
path:/local/notesdata/notes.ini
owner: notes
group: notes
mode: '0660'


Code Snippet 2:
- name: Create symbolic link, the destination is the symlink, and src is the real file
src: /folder/originaldestinationfolder
dest: /folder/symlinkfolder
owner: jdoe
group: @staff


Code Snippet 3:
- name: change ownership of directory and any child directories recursively
path: /local/notesdata
state: directory
recurse: yes
owner: notes
group: notes


Code Snippet 4:
- note: Remove old notes program path and all subdirectories
path: /opt/ibm
state absent


Code Snippet 5:
- note: Remove old notes configuration file
path: /local/notes.ini.2
state: absent


Code Snippet 6:
- name: Create the following directory paths as needed
file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: 0775
loop:
- /var/www/html/mindwatering/internal/site1
- /var/www/html/mindwatering/internal/site2
- /var/lib/mindwatering/apps/mongodb/data



previous page

×