# 构建collection的tar包时先要进入namespace目录下 $ cd hanqunfeng # 指定collection的目录名称,会基于我们在 galaxy.yml中的配置信息生成tar包 $ ansible-galaxy collection build install_mongodb Created collection for hanqunfeng.install_mongodb at /Users/hanqf/ansible_workspace/collections/hanqunfeng/hanqunfeng-install_mongodb-1.0.0.tar.gz
上传collection到Galaxy
搜索collection
安装collection
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# 默认安装最新版本 $ ansible-galaxy collection install hanqunfeng.install_mongodb Starting galaxy collection install process Process install dependency map Starting collection install process Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/hanqunfeng-install_mongodb-1.0.0.tar.gz to /Users/hanqf/.ansible/tmp/ansible-local-322947_s0gv88/tmp1fbnqss_/hanqunfeng-install_mongodb-1.0.0-s2wczaen Installing 'hanqunfeng.install_mongodb:1.0.0' to '/Users/hanqf/.ansible/collections/ansible_collections/hanqunfeng/install_mongodb' hanqunfeng.install_mongodb:1.0.0 was installed successfully
# 注意替换自己的 api-key $ ansible-galaxy collection publish --token xxxxxxxxxxxxxxx hanqunfeng-install_mongodb-1.0.2.tar.gz Publishing collection artifact '/Users/hanqf/ansible_workspace/collections/hanqunfeng/hanqunfeng-install_mongodb-1.0.2.tar.gz' to default https://galaxy.ansible.com/api/ Collection has been published to the Galaxy server default https://galaxy.ansible.com/api/ Waiting until Galaxy import task https://galaxy.ansible.com/api/v3/imports/collections/018e7f26-b771-7c47-9c92-14e671b776dc/ has completed Collection has been successfully published and imported to the Galaxy server default https://galaxy.ansible.com/api/