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

沒有留言:

張貼留言

【IT Notes】透過api移轉Gmail到Exchange

 在雲端裡面串接api不是一件很好學的技術,第一次有機會學習到將GWS的Gmail信件全部轉移到M365的Exchange,其實方法很多種,像以前用的pst檔匯出轉移的方式等,但透過api串接,可以批次和排程轉移,是非常方便且準確的作法。唯一讓人感到困難的是學習成本不小,通常需要...