顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2024年10月7日 星期一

Linux與Windows之爭雜談

 從事IT工作五年了,今天差不多是五年前離開慧科的日子,那時候頂多只會用xampp,而目前已經轉當SE一段時間,自認為有基礎,不過還有待更多經驗的累積。這段時間換過幾份工作環境之後,加上跟同事的聊天發現,Linux和Windows背後都有許多各自的支持者,公司的政策傾向用哪一套系統也跟決策者思維和公司資金很有關係,而兩套系統的背後也影射出自由軟體的支持和反對者的觀點,兩邊對各自所支持的軟體都有很強烈的論點,我想聊一下從業以來的體驗和卓見:

【IT Notes】RHCE測驗補充題 Create and use partitions

Create /home/student/ansible/partition.yml, which will create partitions on managed nodes:

  •  After sdb creating a 1500M primary partition, partition number 1, and format ext4
  •  All groups to permanently mount the partition to /data
  •  If there is not enough disk space, give prompt information  
"Could not create partition of that size"

  •  create 800M partition
  •  If sdb does not exist, a prompt message will be given 
"This disk is not exist"

【題前說明】
這題的做法很類似於第九題,只不過後者是建立邏輯卷宗,而這題是做磁碟切割,難度來說一樣,要會使用不常用的module,首先對每台node的sdb磁區切割出1500MB空間,並將磁區編號命名為1、檔案格式為ext4,根目錄上建立/data資料夾並掛載到sdb1,若磁碟空間不足,要輸出「Could not create partition of that size」的訊息,並將磁區空間分割降為800MB。若完全不存在sdb磁區則是直接輸出「this disk is not exist」。

2024年10月2日 星期三

【IT Notes】RHCE測驗補充題 Use the RHEL system role

 Create a playbook /home/student/ansible/selinux.yml that runs on hosts in the webservers host group and does the following:

  • Uses the selinux RHEL system role.
  • Enables httpd_can_network_connect SELinux boolean.
  • The change must survive system reboot.
【題前說明】
練習的時候沒有出現這題,我猜可能是舊題目,額外在網路上爬到的,因為在練習時有背這題。實際上做法跟第五題一樣,大概是因為過程相同,所以正式考試時只保留其中一題的關係,不過既然都練習過且也有紀錄了,這邊就把它放上來保留著。流程也跟第五題的Roles使用方式一樣,先將mycollection裡面的selinux複製到指定的roles路徑底下,然後寫一個selinux.yml腳本,內容是部署webservers群組內node的selinux config設定為enforcing,也就是強制啟用selinux功能。

【IT Notes】RHCE測驗第十七題 Configure a cron job

Create a playbook called /home/student/ansible/cron.yml that runs on all managed hosts and creates a cron job for user student as follows:

  • The user natasha must configure a cron job that runs every 2 minutes and executes logger “Hello World”

 【題前說明】

完成前面幾題以後,最後這一題算是相對簡單的,只需要在每台主機上建立使用者natasha,並以其身分設定每兩分鐘執行一遍的排程工作,任務就算結束了。

2024年9月10日 星期二

【IT Notes】RHCE測驗第十六題 Rekey an Ansible vault

 Rekey an existing Ansible vault as follows:

【題前說明】

又是一個可以喘口氣的題目,此題只是要考對ansible-vault指令是否熟悉,只需要去data主機把要求的路徑檔案先下載好,然後重新配置檔案的密碼,沒有太多困難的操作,跟上一題比輕鬆很多。

2024年9月5日 星期四

【IT Notes】RHCE測驗第十五題 Create user accounts

  • Download a list of users to be created from http://example.classroom.com/cd/materials/user_list.yml and save it to /home/student/ansible

  • Using the password vault /home/student/ansible/locker.yml created elsewhere in this exam, create a playbook called /home/student/ansible/users.yml that creates user accounts as follows:

    • Users with a job description of developer should be:

      • created on managed nodes in the dev and test host groups
      • assigned the password from the pw_developer variable
      • a member of supplementary group devops
    • Users with a job description of manager should be:

      • created on managed nodes in the prod host group
      • assigned the password from the pw_manager variable
      • a member of supplementary group opsmgr
  • Passwords should use the SHA512 hash format.

  • Your playbook should work using the vault password file /home/student/ansible/secret.txt created elsewhere in this exam.

【題前說明】

這也是一個有相當難度的考題,運用到相當多的迴圈與變數的概念,首先要透過data主機提供的使用者訊資訊yml,內容有user的UID、名稱、群組和密碼變數,再來套用在上一題所創建的加密檔案,內容有變數所需要的帳號和密碼,最後會依照各node所屬群組,分批次方式部署各node索要建立的群組與使用者。難度在於要清楚地分辨哪些node要建立哪些使用者與群組。依據題目內容再解說更詳細一點,這題先要在dev和test的node上,建立devops群組,然後建立屬於devops的使用者與密碼;再於prod的node上,建立opsmgr群組,然後建立屬於opsmgr的使用者與密碼。這些user的密碼皆使用SHA512的加密方式。

2024年8月29日 星期四

【IT Notes】RHCE測驗第十四題 Create a password vault

Create an Ansible vault to store user passwords as follows:

  • The name of the vault is /home/student/ansible/locker.yml

  • The vault contains two variables with names:

    • pw_developer with value Imadev
    • pw_manager with value Imamgr
  • The password to encrypt and decrypt the vault is retent

  • The password is stored in the file /home/student/ansible/secret.txt

【題前說明】

這題要是給喘口氣用的,因為前後兩題都是較難的題型。主要重點是先建立一個secret.txt檔,裡面放的是密碼是retent,再來建立個locker.yml檔,裡面內容是一對變數檔,目的是為了提供後面的另一個題目解題使用,所以看起來簡單,可是若做不出來或錯誤的話,另一題也就會跟著報銷。經過ansible-valut指令會將locker.yml加密,必須要用到secret.txt才能夠解密,雖然簡單但也考驗加密的觀念。

2024年8月23日 星期五

【IT Notes】RHCE測驗第十三題 Generate a hardware report

 Create a playbook called /home/student/ansible/hwreport.yml that produces an output file called /root/hwreport.txt on all managed nodes with the following information:

  • Inventory host name

  • Total memory in MB

  • BIOS version

  • Size of disk device sda

  • Size of disk device sdb

  • Each line of the output file contains a single key=value pair.

Your playbook should:

【題前說明】

這是會用到大量變數概念的題目,解法也很多種,我學的只是一種比較懶惰的寫法,分數可能不高,但仍可以達到題目所要求的結果。首先要去data主機上下載hwreport.empty檔到本地的/root底下,將檔名改成hwreport.txt,檔案裡面的參數很重要,要依照裡面的參數來編輯ansible用部署的變數。基本的邏輯是:key去讀取hwreport.txt裡面的所對應文字當標題,並當作變數的參照;value根據ansible facts去每一台node抓取資料會來當值,並放置到所對應的key後面,若沒有找到相對應的值則輸出NONE。敘述這段好像在繞口令,這題也是我在練習時花免多時間去理解的,難度大概可以排名前三。

2024年8月19日 星期一

【IT Notes】RHCE測驗第十二題 Create a web content directory

 Create a playbook called /home/student/ansible/webcontent.yml as follows:

  • The playbook runs on managed nodes in the dev host group

  • Create the directory /webdev with the following requirements:

    • it is owned by the webdev group
    • it has regular permissions: owner=read+write+execute, group=read+write+execute, other=read+execute
    • it has special permissions: set group ID
  • Symbolically link /var/www/html/webdev to /webdev

  • Create the file /webdev/index.html with a single line of text that reads: Development

  • Browsing this directory on hosts in the dev host group (for example http://node1.example.com/webdev/) produces the following output:

    Development

【題前說明】

前面有幾題在webservers群組上作網站部署,這題則是回到dev群組,也就是node1上也部署一個網頁,而網頁路徑有指定一個資料夾名為/webdev(位於根目錄底下),同時要設定群組、SELinux權限,再來於資料夾內新增index當作首頁,首頁內容為Devlopment,再透過軟連結的方式指向網頁伺服器的根目錄,最後則是開啟防火牆允許apache啟用。難度不算高,但是步驟多也就表示要背的指令及流程也多。

2024年8月15日 星期四

【IT Notes】Windows製作登入Linux金鑰

一直以來都是用帳號密碼來登入Linux,雖然已經知道可以用金鑰登入的方式,可是始終沒有養成習慣,主因是金鑰要好好保管有點麻煩,有時候重灌或是偷懶就會找不到,但最近覺得如果需要安全又方便的話,還是多練一下用金鑰登入主機會比較好。

2024年8月12日 星期一

【IT Notes】RHCE測驗第十一題 Modify file content

 Create a playbook called /home/student/ansible/issue.yml as follows:

  • The playbook runs on all inventory hosts

  • The playbook replaces the contents of /etc/issue with a single line of text as follows:

    • On hosts in the dev host group, the line reads: Development
    • On hosts in the test host group, the line reads: Test
    • On hosts in the prod host group, the line reads: Production

【題前說明】
這一題的重點是變數的運用,先建立一個變數用的資料夾,然後在裡面分別建立Development、Test和Production三個群組的檔案,檔案內容則是變數,最後再回到外面建立yml檔,內容要能夠去讀取變數檔,並且部署到三個群組的/etc/issue底下。整體來說是比較簡單的題目,感覺是給考生稍微放鬆和給分用的。

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,最後還要自己驗證一下結果。

2024年6月27日 星期四

【IT Notes】RHCE測驗第七題 CREATE AND USE A ROLE

 Create a role called apache in /home/student/ansible/roles with the following requirememts:

  • The httpd package is installed, enabled on boot, and started

  • The firewall is enabled and running with a rule to allow access to the web server

  • A template file index.html.j2 exists and is used to create the file /var/www/html/index.html with the following output:

    Welcome to HOSTNAME on IPADDRESS

    where HOSTNAME is the fully qualified domain name of the managed node and IPADDRESS is the IP address of the managed node.

Create a playbook called /home/student/ansible/newrole.yml that uses this role as follows:

  • The playbook runs on hosts in the webservers host group

【題前說明】
這題是要用背的了,要建立一個客製化的roles,自己寫一個apache的yml和輸出客製字符index的template,然後用ansible部署到webserver的node上面,聽起來有點複雜,不過只要弄清楚邏輯和流程,用背的其實也沒有太困難。

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主機上供解題時的下載點。

2024年6月24日 星期一

【IT Notes】RHCE測驗第五題 USE A RHEL SYSTEM ROLE

Making use of the redhat.rhel_system_roles collection installed in another item create a playbook called /home/student/ansible/timesync.yml that:

  • Runs on all managed nodes

  • Uses the timesync role

  • Configures the role to use the currently active NTP provider

  • Configures the role to use the time server 172.25.250.15

  • Configures the role to enable the iburst parameter


【題前說明】
 這題開始要用到roles了,而且也呼應前面第三題,萬一前面做不出來,這題當然也就報銷了。簡單來說,就是把collections裡面的timesyc roles複製到家目錄下剛新建的的roles裡面,然後讓ansible使用它,為每一台node部署校時的chronyd,跟Data主機作時間校對。

2024年5月29日 星期三

【IT Notes】Ubuntu 22.04安裝Zabbix並監控其他主機

 公司使用Zabbix已經很久了,但我一直都沒有自己好好研究和安裝過它,這次剛好有機會要幫用戶監控,所以就從零開始做起,挑選Ubuntu當我的OS,安裝完以後我還要監控其他台Linux和Windows來做測試。

2024年4月3日 星期三

【IT Notes】RHCE測驗第四題 INSTALL PACKAGES

Create a playbook called /home/student/ansible/packages.yml that:

  • Installs the php and mariadb packages on hosts in the dev, test, and prod host groups

  • Installs the RPM Development Tools package group on hosts in the dev host group

  • Updates all packages to the latest version on hosts in the dev host group

【題前說明】
 這是很入門的考題,目的只是要安裝php和mariadb在node1、node2、node3和node4上;然後node1上再多裝dev tools,並且更新每一台node上的套件至最新版本,全部動作都用ansible來部署。

AWS SOA-C03測驗通過心得

 自從換了新公司以來已經過了七個月,因為專案進程沒有太緊迫的時間壓力,一切都是客戶和PM說了算,我也就擁有比較多時間可以進修,剛入職後想延續著CCNA考試剛過的熱度,加減多讀一點課程,後來公司又發布了證照獎勵金的列表和制度,我就發現以前面試過一間雲公司,希望我入職去找AWS SO...