Tasks
Task 1: Working with modules
Based on these examples, add to the initial playbook the following tasks:
File transfer with the module
copy
Create a new directory with the module
file
Delete a whole directory and files (module
file
)Install a list of packages with
yum
Task 2: Cobbler configuration in a role
Let’s create the role cobblerd
for the master node, this role will contain all necessary tasks to install and configure the cobblerd
service. First, add the role to the master.yml
file,
---
# file: master.yml
- name: provisioning for master node
hosts: master
roles:
- ntp_server
- cobblerd
...
Then, create the folders roles/cobblerd
, roles/cobblerd/tasks
and roles/cobblerd/files
. Since the service cobblerd
was already configured manually in exercise 3, we can use the same configuration. Save the files /etc/cobbler/settings
, /etc/cobbler/*.template
, /etc/cobbler/zone_templates/*
and /var/lib/cobbler/kickstarts/*
into the roles/cobblerd/files
folder. After this, create a main.yml
file in cobblerd/tasks
containing the following tasks (see Exercise 3: Setting up a netboot environment with cobbler for more details):
Install EPEL
Install Cobbler, dhcp, bind, tftp-server, pykickstart
Copy Cobbler setting file into place
Copy
*.template
files into placeCopy
zone template/*
files into placeCopy the
kickstart/*
files into placeEnable/start the system services
httpd
,tftp
,named
,cobblerd
anddhcpd
Rebuild the contents of
/tftpboot
and/var/www/cobbler
(i.e.cobbler sync
)
Note that the files in roles/cobblerd/files
can be used directly by any task in the role, i.e. no absolute path is required in the src
declaration. For instance, the Cobbler settings file can be copied into /etc/cobbler/
as follows:
- name: copy cobblerd settings file
copy:
src: settings
dest: /etc/cobbler/settings
owner: root
group: root
mode: "u=rw,g=r,o=r"
force: yes
The cobblerd
tree directory should then look like this:
[root@master cobblerd]# tree .
.
├── files
│ ├── dhcp.template
│ ├── kickstart.ks
│ ├── named.template
│ ├── settings
│ └── zone.template
└── tasks
└── main.yml
Task 3: Managing and propagating local accounts
Add a role to the playbook
master.yml
(see here) calledaccounts_creation
including the following tasks:
Add a role to the compute nodes playbook called
accounts_propagation
to propagate the user accounts and groups created in master node. Tip: use synchronize.
Task 4: Compile and configure LMOD with ansible
Create the necessary roles to configure LMOD in master and in the compute nodes.
Merit Task: Configure a compute node from scratch
Re-image one of the compute nodes and use your ansible roles/playbooks to configure all the services, accounts and software.