Common Ansible modules include:
-
command: Executes a command on a remote host.
- name: Run a command command: /path/to/command -
shell: Executes a shell command on a remote host.
- name: Run a shell command shell: echo "Hello, World!" -
copy: Copies files from the control machine to the remote host.
- name: Copy a file copy: src: /local/path/to/file dest: /remote/path/to/file -
file: Manages file properties (e.g., permissions, ownership).
- name: Set file permissions file: path: /path/to/file mode: '0644' -
template: Renders a Jinja2 template and copies it to the remote host.
- name: Deploy a configuration file template: src: template.j2 dest: /etc/config.conf -
yum: Manages packages using the YUM package manager (for Red Hat-based systems).
- name: Install a package yum: name: httpd state: present -
apt: Manages packages using the APT package manager (for Debian-based systems).
- name: Install a package apt: name: apache2 state: present -
service: Manages services (start, stop, restart).
- name: Ensure a service is running service: name: httpd state: started -
user: Manages user accounts on the remote host.
- name: Create a user user: name: newuser state: present -
git: Manages Git repositories.
- name: Clone a Git repository git: repo: 'https://github.com/user/repo.git' dest: /path/to/destination
These modules cover a wide range of tasks, from file management to package installation and service management, making them essential for automating IT tasks with Ansible.
