As a system administrator, you will need to install software on the managed nodes. Create the playbook /home/student/ansible/yum_repo.yml which creates the following yum repositories on each of the managed nodes as follows:
Repository 1:
- The name of the repository is EX294_BASE
- The description is EX294 base software
- The base URL is http://example.classroom.com/repos/baseos
- GPG signature checking is enabled
- The GPG key URL is http://example.classroom.com/repos/RPM-GPG-KEY-Rocky-9
- The repository is enabled
Repository 2:
- The name of the repository is EX294_STREAM
- The description is EX294 stream software
- The base URL is http://example.classroom.com/repos/appstream
- GPG signature checking is enabled
- The GPG key URL is http://example.classroom.com/repos/RPM-GPG-KEY-Rocky-9
- The repository is enabled
【題前說明】
這題在RHCE8不是用yml來做的,而是用shell的方式安裝yum repo,到了RHCE9以後就變成要求要用ansible執行yml來部署,這題要是做不出來的話,當然後面的很多題目可能也就沒有檔案可以下載,最後考試也泡湯了。如同下面的第三題,這兩題讓我印象深刻,因為我是上RHCE8,但考前上了衝刺班得到了改版後改提也變更的資訊,一個禮拜之內趕緊補強這幾題,幸虧最後來得及複習,但考是坐我旁邊的同學就沒那麼幸運,記得當時他很慌張,因為他也跟我一樣是上一版本的課程,不過他沒有上衝刺班,等於第二和第三題他都不曉得,所以得要強調這幾題目前的變化!
一.解題過程:
1.建立yum_repo.yml檔
[student@workstation ansible]$ touch yum_repo.yml
[student@workstation ansible]$ vim yum_repo.yml
---- name: create yum repos hosts: all tasks: - name: import rpm key rpm_key: key: http://example.classroom.com/repos/RPM-GPG-KEY-Rocky-9 state: present - name: create BaseOS repo yum_repository: name: EX294_BASE description: EX294 base software baseurl: http://example.classroom.com/repos/baseos enabled: yes gpgcheck: yes - name: create AppStream repo yum_repository: name: EX294_STREAM description: EX294 stream software baseurl: http://example.classroom.com/repos/appstream enabled: yes gpgcheck: yes
2.使用ansible-play -C yum_repo.yml或者是ansible-play --syntax yum_repo.yml,驗證一下yml檔有沒有問題
一樣如果要反覆做題目的話,需要做一個yml來恢復變更前的環境。
[student@workstation ansible]$ vim 02-lab-yumrepo-stop.yml
---- name: remove all repo hosts: all tasks: - name: remove base repo shell: sudo rm -f /etc/yum.repos.d/EX294_BASE.repo
- name: remove centosplus repo shell: sudo rm -f /etc/yum.repos.d/EX294_STREAM.repo
- name: remove repo.yml hosts: 127.0.0.1 tasks: - name: remove repo.yml file: path: /home/student/ansible/yum_repo.yml state: absent
[student@workstation ansible]$ ansbile-playbook 02-lab-yumrepo-stop.yml
沒有留言:
張貼留言