上一章「Ansible 在 Ansible Galaxy 分享 Roles(上)」,我們幫 Role 補(bǔ)充了 Galaxy 網(wǎng)站所需的資訊,接下來(lái)就是把它分享到 Galaxy 上了!
先前在「Ansible 怎么使用 Roles」一章曾提過(guò),Galaxy 里的 Roles 其實(shí)是存在 GitHub 上的。
ansible-role-acme
的格式進(jìn)行命名。把寫(xiě)好的 Roles 加入 Git 版本控制里。
$ git commit -a
$ git push
借由 Git 從本地 (Local) 把 Roles 上傳至 GitHub。
進(jìn)入 Galaxy 網(wǎng)站,并點(diǎn)擊右上角的 SIGN IN。
使用 GitHub OAuth 登入 Galaxy 網(wǎng)站。
進(jìn)入 My Roles 頁(yè)面,并點(diǎn)選左方按鈕啟用 Roles,完成后將顯示 ?。
當(dāng) Roles 太多時(shí),可借由右方的搜尋框進(jìn)行過(guò)濾。
啟用 Role 后,點(diǎn)擊右方的 Import Role 圖示進(jìn)行匯入。
匯入成功后將顯示 Succeeded,點(diǎn)擊 Succeeded 即可觀看這次匯入的相關(guān)資訊。
我們可借由此頁(yè)面檢查 Meta Data (
meta/main.yml
) 的設(shè)定是否有誤。
若想自定 Role name,可通過(guò) Role Settings 進(jìn)行更改。
以上,現(xiàn)在我們可以在 https://galaxy.ansible.com/chusiang/testlink/ 看到剛匯入的 Role,其中 chusiang
為 username,testlink
為 role name,而完整名稱(chēng)則是 chusiang.testlink
。
寫(xiě)完復(fù)雜 Playbooks,我們只需再費(fèi)點(diǎn)工夫就可以在 Galaxy 上與全世界分享了!
1. 若不會(huì)在 GitHub 上建立 Repository,可參考 Create A Repo | GitHub 一文。 ?
更多建議: