自行建立Ansible執行環境使用ansible-navigator指令工具
文/毛石磊 Leslie Mao
Ansible是一個開源的IT自動化引擎,可自動化進行服務的供應、系統的設定管理、大量應用程式部署、IT工作的編排,以及許多其他IT流程自動化的管理部署。Ansible開源專案受益於數千名貢獻者的經驗和智慧,提供給系統管理人員或開發人員免費使用。
Red Hat Enterprise Linux 9系統的安裝光碟來源裡,已經提供了ansible-core的RPM套件,安裝完成就可以使用本機系統當作Ansible相關資源的執行環境;若要使用Container作為執行環境,則需要另行安裝ansible-navigator的指令工具套件,但RHEL 9的安裝光碟裡並未提供,須另行使用Ansible上游開發者提供的Python pip套件進行安裝。相關資訊可查詢以下文件:Ansible Navigator Documentation。
安裝步驟如下
請先以管理員帳號安裝ansible-core、python3-pip和container-tools套件:
[root@test ~]# dnf -y install ansible-core python3-pip container-tools

接下來即可以一般使用者帳號進行後續工具的安裝,及使用Ansible進行自動化部署時Playbook的撰寫: [student@test ~]$ python3 -m pip install ansible-navigator --user

預設ansible-navigator指令工具會安裝在 ~/.local/bin/

ansible-navigator指令工具安裝完成後,需要使用Container作為執行環境,而RedHat提供了開發人員,可以免費使用官方的Image,來運作Container,只要使用者完成開發者帳號的服務訂閱。參與RedHat開發人員計畫免費取得訂閱服務,請參考以下文件:红帽企業Linux開發人員計畫。
為了在執行ansible-navigator指令工具時,可自動下載RedHat官方的ee-supported-rhel8具有Ansible執行環境的Image,需要在使用者家目錄下,產生一個 ~/.ansible-navigator.yml 的隱藏檔,內容如下:
[student@test ~]$ vim ~/.ansible-navigator.yml
ansible-navigator: execution-environment: image: registry.redhat.io/ansible-automation-platform-22/ee-supported-rhel8:latest pull: policy: missing playbook-artifact: enable: false

接下來使用開發人員帳號登入 registry.redhat.io: [student@test ~]$ podman login registry.redhat.io

可以使用ansible-navigator images指令確定是否可以成功下載Container Image使用: [student@test ~]$ ansible-navigator images

確定ee-supported-rhel8的Container Image已經下載成功,可使用 :q 指令離開。

0 意見:
張貼留言