您现在的位置是:首页 > 文章详情

通过 ansible 创建 openstack 虚拟机并部署应用(配置篇)

日期:2018-04-23点击:443

本文中的例子在 ansible 和 Ansible Tower 里都通过。

controller 对 openstack 的接入

本文里的 controller 是我的笔记本电脑,需要做以下配置:

建立 /etc/ansible/openstack.yml,内容如下

clouds: poc: auth: username: 'admin' password: xxxxxxxxxxxxxxxxxxxxx project_name: 'Haibin_Lee' auth_url: 'http://192.168.205.2:5000/v2.0' region_name: RegionOne ansible: use_hostnames: True expand_hostvars: True fail_on_errors: True

auth 里的是 openstack 的相关验证信息。然后在你的 ansible 项目根目录下下载 openstack.py

wget https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py chmod +x openstack.py

验证你的配置

./openstack.py --list

如果正确,会列出你的 openstack 服务里的 hosts

然后在你的 ansible 项目根目录下放置独立的 ansible.cfg 文件并修改它的内容,

[defaults] inventory = ./openstack.py

这样就可以动态加载 openstack 里的服务器 inventory 了。

官方文档 http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html#example-openstack-external-inventory-script

手动在对应的 openstack 集群里创建一台虚拟机,用于执行 ansible 剧本,创建新虚拟机用。本文中命名为 openstack-connector,使用 ubuntu 14.04 版本系统。

在 openstack-connector 里安装以下软件

sudo apt-get install gcc libssl-dev sendmail python-pip sudo -H pip install -U pip sudo -H pip install cryptography shade

检查状态 ./openstack.py --host openstack-connector,你可以看到很长一串的 json 格式输出。

最后把你的公钥拷贝到 openstack-connector 里,我这台机器的 IP 是 192.168.220.57。

ssh-copy-id root@192.168.220.57

基本环境就搭好了。

接着请看 通过 ansible 创建 openstack 虚拟机并部署应用(实战篇)

原文链接:https://yq.aliyun.com/articles/584437
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章