2024年6月25日 星期二

【IT Notes】RHCE測驗第六題 INSTALL ROLES USING ANSIBLE GALAXY

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:


【題前說明】
 這題要用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


要看到successfully的訊息才成功



二.驗證結果
檢查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

沒有留言:

張貼留言

宜蘭又淹水

 突然來了一個看起來不是很強的颱風,結果外圍環流一夜之間就把宜蘭給淹了,而且受害最嚴重的蘇澳又跟15年前的梅姬颱風一樣,把整個小鎮淹了一層樓高,那時候我還在金六結營區,時間也是10~11月左右,彷彿又像是歷史重演一般。