ansible-playbook-批量修改主机名

 

修改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 }}"

 

转载于:https://www.cnblogs.com/Qing-840/p/9264117.html

你可能感兴趣的:(ansible-playbook-批量修改主机名)