Last active
November 8, 2018 08:16
-
-
Save peerapach/357012fe124b27e938ae970bc7d622a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
vars: | |
tasks: | |
- name: Install required packages | |
package: | |
name: "{{ item }}" | |
state: present | |
with_items: | |
- docker | |
- NetworkManager | |
- wget | |
- net-tools | |
- bind-utils | |
- iptables-services | |
- yum-utils | |
- bridge-utils | |
- kexec-tools | |
- sos | |
- psacct | |
- epel-release | |
- name: configure NetworkManager | |
lineinfile: | |
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ ansible_default_ipv4['interface'] }}" | |
regexp: '^{{ item }}=' | |
line: '{{ item }}=yes' | |
state: present | |
create: yes | |
with_items: | |
- 'USE_PEERDNS' | |
- 'NM_CONTROLLED' | |
- name: Restart NetworkManage and docker | |
systemd: | |
name: "{{ item }}" | |
state: restarted | |
enabled: True | |
with_items: | |
- NetworkManager | |
- docker | |
- name: Build hosts file | |
lineinfile: | |
dest: /etc/hosts | |
regexp: '.*{{ item }}$' | |
line: "{{ hostvars[item].ansible_default_ipv4.address }} {{item}} {{hostvars[item].inventory_hostname_short}}" | |
state: present | |
when: | |
- "{{hostvars[item].ansible_default_ipv4.address is defined}}" | |
with_items: | |
- "{{ groups['all'] }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment