神甫 发表于 2018-7-29 07:19:59

ansible基于ansible-playbook 做文件传参数

  有一个较为通用的节点部署playbooks,在每次部署的时候传递一个版本号或者用户信息之类的
  例子:
  - hosts: '{{ hosts }}'
  remote_user: '{{ user }}'
  tasks:
  - name: 创建/tmp/hanye目录
  shell: mkdir /tmp/'{{ hanye }}'
  执行命令:
  ansible-playbooknginx_like.yml--extra-vars "hosts=web user=root hanye=hanye"
  执行结果查看
  root@debian:/home/sh/ansible_temp# ansible web -m shell -a "ls /tmp|grep hanye"
  192.168.1.44 | success | rc=0 >>
  hanye
  192.168.1.40 | success | rc=0 >>
  hanye
  192.168.1.43 | success | rc=0 >>
  hanye
  192.168.1.46 | success | rc=0 >>
  hanye
页: [1]
查看完整版本: ansible基于ansible-playbook 做文件传参数