一.DNS配置
1.1.文件结构
├── hosts
├── roles
│ ├── DNS
│ │ ├── handlers
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
└── site.yml
1.2.DNS任务下任务主文件
/roles/DNS/tasks/main.yml
#配置DNS地址
- name: add_DNS
lineinfile:
dest: /etc/sysconfig/network-scripts/ifcfg-eth0
line: "DNS1=xx.xx.xx.xx"
state: present
notify:
- restart_network
#配置快速登陆
- name: ssh no DNS
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "{{item.old}}"
line: "{{item.new}}"
state: present
with_items:
- {old: 'UseDNS yes', new: 'UseDNS no' }
- {old: 'GSSAPIAuthentication yes' ,new: 'GSSAPIAuthentication no' }
notify:
- restart_sshd
- meta: flush_handlers
1.3.DNS任务下操作文件
/roles/DNS/handlers/main.yml
- name: restart_network
service: name=network state=restarted
- name: restart_sshd
service: name=sshd state=restarted