Use Ansible Galaxy with a requirements file called /home/student/ansible/roles/requirements.yml to download and install roles to the default roles directory /home/student/ansible/roles from the following URLs:
http://example.classroom.com/materials/haproxy.tar The name of this role should be balancer
http://example.classroom.com/materials/phpinfo.tar The name of this role should be phpinfo
這題要用ansible galaxy安裝兩個function,分別是php和負載平衡功能,題目其實很簡單,我覺得比較難的是我自己模擬不出load balance的功能,這兩支程式是從補習班老師那邊取得的,抓過來我就直接放在Data主機上供解題時的下載點。
一.解題過程:
[student@workstation ansible]$ vim requirements.yml
---
- src: http://example.classroom.com/cd/exam_ehce8/haproxy.tar.gz
name: balancer
- src: http://example.classroom.com/cd/exam_ehce8/phpinfo.tar.gz
name: phpinfo
[student@workstation ansible]$ ansible-galaxy role install -r requirements.yml
二.驗證結果
檢查roles資料夾下有沒有安裝好
這題要做的事情不多,不過下面還有題目會用到這邊的roles,所以還是不能做不出來或大意。
三.恢復解題前的環境
[student@workstation ansible]$ vim 06-lab-requirements-stop.yml
---- name: remove downloaded roles hosts: 127.0.0.1 tasks: - name: remove role balancer and phpinfo shell: ansible-galaxy remove "{{ item }}" loop: - balancer - phpinfo
- name: remove requirements file file: path: /home/student/ansible/requirements.yml state: absent
[student@workstation ansible]$ ansible-playbook 06-lab-requirements-stop.yml
沒有留言:
張貼留言