Open main menu

CDOT Wiki β

Changes

OPS445 Online Lab9

314 bytes added, 13:12, 16 July 2023
Investigation 1: The Ansible Package
= System requirements =
* You must have a control machine and a valid Seneca user account on matrix.senecacollege.ca and an VM assigned to you in myvmlab.senecacollege.ca:** control machine (matrix.senecacollege.caor your Fedora)- run ansible to configure your assigned VM in myvmlab.senecacollege.ca
** managed machine(s) (your vm in myvmlab.senecacollege) - to be managed by the control machine
* You should be able to ssh from matrix.senecacollege.ca your control machine as a regular user to your managed machine without supplying a login password.
* Your account on your managed machine is a sudoer and can run sudo with/without password.
* Has Ansible installed on your control machine.
* Has Python 2.7+ installed on your managed machine(s).
 = Investigation I1: The Ansible Package =
: In this investigation, we explore the main components of the Ansible configuration management system and its operating environment. We also study a simple playbook for managing the configuration of a CentOS 7.x VM.
: You need at least two Linux systems for this lab: your account on matrix.senecacollege.ca to be used as the control machine and your assigned VM in myvmlab.senecacollege.ca as the managed machine. The Ansible package is already installed on matrix for you.
== Part 1: The Ansible package installed on matrix ==
: You only need to have the "ansible" package on your control VM (i.e: On Fedora, Ansible is provided in the ansible package. matrix)Run: <source lang="bash">dnf install ansible</source>: On Matrix, Ansible is already installed for you.
:* Login to matrix with your Seneca account and change to the directory ~/ops445/lab9
:* Issue the following command to check the version of the "ansible" package: <source lang="bash">
[[OPS445_Ansible_setup|Click here for complete sample contents of the above]]
= Investigation II2: Ansible Playbook =
== What is a playbook? ==
: * Playbook is one of the core features of Ansible.
hosts: vmlab
user: instructor
become: yes
vars:
apache_version: 2.6
motd_warning: '"WARNING: user used by ICT faculty/students only.'\n"
testserver: yes
tasks:
Sample Run:
<pre>
[raymond.chan@mtrx-node02pd lab9]$ ansible-playbook -i hosts --private-key ~/.ssh/id_rsa -b motd-play.yml
PLAY [update motd file] *******************************************************************
<pre>
---
- hosts: 192.168.99.153vmlab user: rootinstructor become: yes
vars:
apache_version: 2.6
motd_warning: '"WARNING: use used by ICT faculty/students only.'\n"
testserver: yes
tasks:
Sample Run:
<pre>
[rchan@centos7 playbooks]$ ansible-playbook -i hosts httpd-play.yml
PLAY [192.168.99.153vmlab] ********************************************************************
TASK [Gathering Facts] **********************************************************ok: [192.168.99.153vmlab]
TASK [install apache] ***********************************************************changed: [192.168.99.153vmlab]
TASK [restart apache] ***********************************************************changed: [192.168.99.153vmlab]
PLAY RECAP **********************************************************************192.168.99.153 vmlab : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
</pre>
 = Investigation III3: Using Playbook to configure an OPS445 Linux VM machine =
: Assume you have just installed the latest version of CentOS 7.x on a VM with GNOME Desktop. You need to configure it so that you can use it for doing the Labs for OPS445.
: Study the documentation and examples of following ansible modules:
:* yum
Create an ansible playbook named "config_ops445.yml" using the appropriate modules to perform the following configuration tasks on your assigned VM::* update all the packages Apache (httpd) installed on in the VMInvestigation 2 - Part 2:* install extra packages repository for enterprise Linux:* install python3 (EPEL) if it is not already installed:* remove 'tree' package:* set the host name hostname to your Seneca user name:* install the git packageusername (Seneca ID):* create a new user with your Seneca_id Seneca_ID with sudo access:* configure the new user account you created above so that you can ssh to it without password:* setup a directory structs structure '''using a loop''' for completing and organizing labs as shown below:<source lang="bash"> /home/[seneca_id]/ops445/lab0
/home/[seneca_id]/ops445/lab1
/home/[seneca_id]/ops445/lab2
/home/[seneca_id]/ops445/lab9
</source>
:* create a when it's ready, run your playbook named "config_ops445.yml" :* in order to perform test it, log into the tasks mentioned above.VM with the newly created user (your Seneca_ID), install the 'tree' package with sudo, and check the directory structure with the 'tree' command:* test and if everything is correct, capture its output for a successful run of your playbook to a file named "lab9_[seneca_id].txt"
= Lab 9 Sign-off (Show Instructor) =
== Have the following items ready to show your instructor: ==
: * The Ansible playbook called "config_ops445.yamlyml" for configuring the VM mentioned in Lab 1.: * The result of running the playbook "config_ops445.yamlyml". Save the result in a file called "lab9_[seneca_id].txt"
== Upload the following files to blackboard ==
: * config_ops445.yamlyml
: * lab9_[seneca_id].txt