Ansible整理

[root@ansible ~]# yum -y install ansible
[root@ansible ~]# yum remove ansible
[root@ansible ~]# ansible-doc cron     #查看cron模块详细帮助信息
[root@ansible ~]# ansible-doc -s cron     #查看cron模块简要信息
[root@ansible ~]# ansible hostname|ip -m setup     #获取ansible内置变量(内置变量调用方式:ansible_eth0.ipv4.address)
[root@ansible ~]# ansible-playbook -i /root/hosts.txt test.yaml    #ansible执行自定义主机文件
#hosts.txt文件格式

192.168.1.2  ansible_ssh_user=root    ansible_ssh_pass='PASSWORLD'
192.168.1.3  ansible_ssh_user=root    ansible_ssh_pass='PASSWORLD'

[web]
192.168.1.2

[db]
192.168.1.3

[hosts:children]
web
db

#定义变量
[hosts:vars]
domain="www.test.com"

#test.yaml文件格式

- name: Initalize system
  hosts: hosts
  remote_user: root
  gather_facts: True
  roles:
    - role: web
      tags: init

解决ansible cryptography模块告警
[root@ansible ~]# ansible 127.0.0.1 -m ping
/usr/local/python2.7/lib/python2.7/site-packages/ansible-2.9.18-py2.7.egg/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.exceptions import InvalidSignature
[root@ansible ~]# pip2.7 install cryptography==2.9

参考链接:
      https://blog.51cto.com/wujianwei/2082880   #ansible不配置ssh免密钥,使用密码登录
      http://www.ansible.com.cn/docs/playbooks_intro.html  #about-playbooks
      https://www.cnblogs.com/yanjieli/p/10969299.html
      https://www.cnblogs.com/coolops/p/12793640.html
      https://www.likecs.com/show-40538.html
      https://my.oschina.net/kangvcar/blog/1830155
      https://github.com/openstack/kolla-ansible

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值