final exam

 Write a playbook ~/playbooks/logrotate.yml to configure log-rotation on remote hosts.

Complete the following tasks:

  1. grab the module from GitHub: https://github.com/arillso/ansible.logrotate Use ansible-galaxy install command install inside /home/thor/playbooks/roles If you stumbled upon the issue, could not find/use git, install git in the ansible-runner first and install the role.

  2. configure your log rotation rules as:

    • daily
    • rotate 3
    • compress
      …to rotate a log file that would present on location /var/log/myapp.log


That means rotate daily, compress the log file and keep the last three rotations. Check on the options section that the role provides. Since this role depends on facts on remote hosts, make sure to gather facts is not false.






nstall the role using ansible-galaxy
ansible-galaxy install git+https://github.com/arillso/ansible.logrotate --roles-path ~/playbooks/roles
Update roles/ansible.logrotate/defaults/main.yml and modify logrotate_applications section as below:
logrotate_applications:
  - name: myapp
    definitions:
      - logs:
          - /var/log/myapp.log
        options:
          - daily
          - rotate 3
          - compress
Create logrotate.yml playbook and add below given code
---
- hosts: all
  gather_facts: yes
  roles:
    - ansible.logrotate

Comments

Post a Comment

Popular posts from this blog

exam 16

ansible 5

practical 3