Skip to content

Latest commit

 

History

History
84 lines (61 loc) · 3.01 KB

Ansible Manage Services.md

File metadata and controls

84 lines (61 loc) · 3.01 KB

Problem Statement


Developers are looking for dependencies to be installed and run on Nautilus app servers in Stratos DC. They have shared some requirements with the DevOps team. Because we are now managing packages installation and services management using Ansible, some playbooks need to be created and tested. As per details mentioned below please complete the task:

  • a. On jump host create an Ansible playbook /home/thor/ansible/playbook.yml and configure it to install vsftpd on all app servers.

  • b. After installation make sure to start and enable vsftpd service on all app servers.

  • c. The inventory /home/thor/ansible/inventory is already there on jump host.

  • d. Make sure user thor should be able to run the playbook on jump host.

Note: Validation will try to run playbook using command ansible-playbook -i inventory playbook.yml so please make sure playbook works this way, without passing any extra arguments.

Solution

  1. Navigate to the Ansible directory:

    cd /home/thor/ansible
  2. Create the Ansible playbook file: Use a text editor to create and edit the playbook.yml file.

    vi playbook.yml
  3. Add the following YAML configuration to the playbook.yml file:

    ---
    - hosts: all
      become: yes
      tasks:
        - name: Install vsftpd on all app servers
          yum:
            name: vsftpd
            state: present
        - name: Start and enable the vsftpd service
          service:
            name: vsftpd
            state: started
            enabled: true
  4. Test the playbook: Execute the following command to run the playbook using the specified inventory file:

    ansible-playbook -i inventory playbook.yml

Expected Output

When you run the playbook, you should see output similar to the following, indicating that the playbook has successfully installed vsftpd, started, and enabled the service on all app servers:

PLAY [all] ******************************************************************************

TASK [Gathering Facts] ******************************************************************
ok: [stapp01]
ok: [stapp03]
ok: [stapp02]

TASK [Install vsftpd on all app servers] ************************************************
ok: [stapp03]
ok: [stapp01]
ok: [stapp02]

TASK [Start and enable vsftpd service] **************************************************
ok: [stapp01]
ok: [stapp02]
ok: [stapp03]

PLAY RECAP ******************************************************************************
stapp01                    : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
stapp02                    : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
stapp03                    : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

This output indicates that all tasks were executed successfully and no changes were required because the vsftpd service was already in the desired state.