Ansible Galaxy role 登録

role登録

(github.com)
プロジェクト作成
https://github.com/kurita0/ansible-role-nagios_check_mfi

cd ansible-role-nagios_check_mfi

README.md
meta/main.yml
を追加

git init
git add .
git commit -m "first commit"
git remote add origin git@github.com:kurita0/ansible-role-nagios_check_mfi.git
git push -u origin master

(galaxy.ansible.com)
My Content
https://galaxy.ansible.com/my-content/namespaces
Add Content
Import Role from GitHub

roleを使う
ansible-galaxy install kurita0.nagios_check_mfi
roleを更新

github にコミットして

ansible-galaxy install -f  kurita0.nagios_check_mfi

Playbookを一旦開発し終わった後でも、ロールに対して修正することがよくあります
そんなときに、再度インストールし直すには、fオプションつけないと更新できません。
Ansible Galaxyでロールの管理 - コマンド編 - kikukawa's diary

参考

Ansible の Role を Ansible Galaxy に登録し再利用
https://qiita.com/kouji-kojima/items/2525ea87952d4039bad7

roleを作成してAnsible Galaxyに登録するワークフロー
https://qiita.com/hnakamur/items/4c5abbbbbb5623ce46ad

が参考になった

role用のgithubレポジトリ名

role用のgithubレポジトリ名はrole名と同じにしない
role名とレポジトリ名を同じにしてしまうと、Ansible roleが扱うupstreamのソフトウェアのレポジトリをforkするときに名前が衝突してしまいます。例えばnginxのroleをnginxという名前でgithubレポジトリを作ってしまうと、nginx自体のレポジトリをforkするときに困ってしまいます。そこで、role用のgithubレポジトリにはansible-role-という接頭辞をつけることにしました。

https://qiita.com/hnakamur/items/4c5abbbbbb5623ce46ad

Use galaxy_info.role_name, if set in meta/main.yml

https://github.com/ansible/galaxy/issues/498

githubレポジトリはansible-role-xxx に
meta/main.yml の galaxy_info.role_name: xxx にする

On pushing the change that sets this metadata tag, every one of our roles with a hyphenated name was silently converted to using underscores instead.

https://www.stackhpc.com/galaxy-broken.html

role_nameのハイフンはアンダースコアに変わる

参考

ansible で role を新規作成して ansible galaxy で公開して更新した
https://blog.n-z.jp/blog/2017-06-03-ansible-galaxy-new-role.html

https://galaxy.ansible.com/geerlingguy
https://github.com/geerlingguy

Add 'update' option to ansible-galaxy #6466
https://github.com/ansible/ansible/issues/6466