ansible file module code example
Example 1: ansible create folder
- name: Create a directory if it does not exist
ansible.builtin.file:
path: /etc/some_directory
state: directory
mode: '0755'
Example 2: ansible package
- name: install ntpdate
package:
name: ntpdate
state: present
# This uses a variable as this changes per distribution.
- name: remove the apache package
package:
name: "{{ apache }}"
state: absent
- name: install the latest version of Apache and MariaDB
package:
name:
- httpd
- mariadb-server
state: latest