配置文件查找优先级,通常每个配置文件会创建单独的文件夹
ANSIBLE_CONFIG添加变量
ansible.cfg全局
.ansible.cfg局部
/etc/ansible/ansible.cfg
[defaults]
inventory = /etc/ansible/inventory #定义主机名单
forks = 15 #ansible执行并发数
gather_facts: true #每次执行开启facts收集
gather_timeout = 20 #收集fact超时时间
timeout = 20 #ssh连接超时时间
executable = /bin/sh #ansible命令执行shell
fact_caching_connection=/tmp #定义ansible facts缓存路径
[root@localhost ~]$ ansible-doc -l # 列出所有模块
[root@localhost ~]$ ansible-doc cron # 查看指定模块的文档
ansible-playbook –syntax-check检查语法
ansible-playbook -C测试运行
ansible all -i localhost, -m debug -a "msg={
{ '密码' | password_hash('sha512', 'mysecretsalt') }}"生成password
lineinfile
path:
line:
backup:
create:
yum
name: 软件包名称 | URL地址 | 本地的某个路径下的rpm包
state: 具体动作 present absent latest安装最新版本
exclude: 排除
enablerepo: 通过哪个仓库安装
disablerepo: 安装时不使用哪个仓库
copy
src: #当前管理机的配置文件路径
content: