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

沒有留言:

張貼留言

【少年回憶】尋夢谷

 「尋夢谷」這個地名,在我人生中是一個很深刻的存在。那大約是國中二年級的事情了吧,距離現在快要三十年了。後來重新找到這個地方的時候,這裡只剩下大門和一處房舍,尤其是後者,讓我一看到馬上就能辨識出來;至於剩下的其他地方,如今只剩下一片荒煙蔓草、汽車駕訓班和工寮。 為什麼此處留有我那...