2024年7月25日 星期四

【IT Notes】RHCE測驗第十題 Generate a hosts file

  • Download an initial template file from http://example.classroom.com/cd/materials/hosts.j2 to /home/student/ansible

  • Complete the template so that it can be used to generate a file with a line for each inventory host in the same format as /etc/hosts

  • Download the file from http://example.classroom.com/cd/materials/hosts.yml to /home/student/ansible/hosts.yml. This playbook will use the template to generate the file /etc/myhosts on hosts in the dev host group.

    • Do not make any changes to the playbook.

When the playbook is run, the file /etc/myhosts on hosts in the dev host group should have a line for each managed host:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

172.25.250.10 node1.example.com node1
172.25.250.11 node2.example.com node2
172.25.250.12 node3.example.com node3
172.25.250.13 node4.example.com node4
172.25.250.14 node5.example.com node5

NOTE: The order in which the inventory host names appear is not important.

【題前說明】

這一題要做的是去data主機下載兩個檔案,一個是hosts.j2作為template;另一個是hosts.yml作部署用檔案,比較困難的是又要用到查詢ansible facts的能力,將查詢到的node上的facts,寫在hosts.j2裡面當作變數,並且作一個迴圈,讓最後ansible跑部署的時候把五台node的IP address、FQDN和Hostname寫成一個myhost檔,然後只放在dev群組的主機指定路徑底下。


2024年7月15日 星期一

【IT Notes】RHCE測驗第九題 CREATE AND USE A LOGICAL VOLUME

 Create a playbook called /home/studnet/ansible/lvm.yml that runs on all managed nodes that does the following:

  • Creates a logical volume with these requirements:

    • The logical volume is created in the research volume group
    • The logical volume name is data
    • The logical volume size is 1500 MiB
  • Formats the logical volume with the ext4 filesystem

  • If the requested logical volume size cannot be created, the error message

    Could not create logical volume of that size

    should be displayed and the size 800 MiB should be used instead.

  • If the volume group research does not exist, the error message

    Volume group does not exist

    should be displayed.

  • Does NOT mount the logical volume in any way.

【題前說明】
這題是較困難的題目之一,如果是用指令處理的話很快,但要用ansible部署的話就變得比要複雜,主要是要用到的module較多一些。基本的邏輯是,主機上research這個volume group者,先建立一個1500MB的lvm,如果空間不夠,族輸出「Could not create logical volume of that size的訊息,然後改成800MB,並且命名為data;主機上沒有research這個volume group的話,則輸出「Volume group does not exist」的訊息。

2024年7月9日 星期二

【IT Notes】地端主機mount AWS S3的方式

 混合雲大概是不可避免的趨勢,有時候主機放在地端會比較便宜且方便,若遇到要串接雲端的時候,這又變成了一門學問,這次要測試的主題是在地端的Linux主機mount AWS的S3,過程有一點小繁瑣,必須記錄一下以免之後會用得到。流程是先新建一個S3 Bucket、建立傳遞的user與role,最後在地端主機上mount S3 Bucket。

2024年7月4日 星期四

【IT Notes】RHCE測驗第八題 USE ROLES FROM ANSIBLE GALAXY

 Create a playbook called /home/student/ansible/roles.yml with the following requirements:

  • The playbook contains a play that runs on hosts in the balancers host group and uses the balancer role.

    • This role configures a service to load balance web server requests between hosts in the webservers host group.
    • Browsing to hosts in the balancers host group (for example http://node5.example.com/) produces the following output:
      Welcome to node3.example.com on 172.25.250.12
    • Reloading the browser produces output from the alternate web server:
      Welcome to node4.example.com on 172.25.250.13
  • The playbook contains a play that runs on hosts in the webservers host group and uses the phpinfo role.

    • Browsing to hosts in the webservers host group with the URL /hello.php produces the following output:

      Hello PHP World from FQDN

      where FQDN is the fully qualified domain name of the host.

    • For example, browsing to http://node3.example.com/hello.php, produces the following output:

      Hello PHP World from node3.example.com

      along with various details of the PHP configuration including the version of PHP that is installed.

    • Similarly, browsing to http://node4.example.com/hello.php, produces the following output:

      Hello PHP World from node4.example.com

      along with various details of the PHP configuration including the version of PHP that is installed.


【題前說明】

這題落落長寫了一大堆看似很嚇人,卻是解題過程最短的,乍看之下以為要做什麼大工程,其實就只是把第六題下載並安裝好的兩個roles分別套用到兩個群組上:balancer套用在balancers群組上;phpinfo套用在webservers群組,用的指令是ansible-galaxy,最後還要自己驗證一下結果。

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

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