运维开发网

批量修改主机名 ansible

运维开发网 https://www.qedev.com 2020-10-08 12:47 出处:51CTO 作者:点解甘假
修改cat/etc/ansible/hosts[test]10.27.235.108host_name=test_host_namehosts:testuser:rootgather_facts:truetasks:name:rsyncdirfilebeathostname:'name={{host_name}}'name:"addline"lineinfile

修改cat /etc/ansible/hosts

[test]

10.27.235.108 host_name=test_host_name

  • hosts: test

    user: root

    gather_facts: true

    tasks:

  • name: rsync dir filebeat

    hostname: 'name={{ host_name }}'

  • name: "add line"

    lineinfile:

    dest: /etc/hosts

    line: "{{ ansible_all_ipv4_addresses[0] }} {{ host_name }}"

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号