Authored by Your Name

替换resolv role

@@ -2,7 +2,8 @@ @@ -2,7 +2,8 @@
2 # playbook files for emr resolv 2 # playbook files for emr resolv
3 - hosts: emr-recom,emr-dw 3 - hosts: emr-recom,emr-dw
4 remote_user: root 4 remote_user: root
5 - 5 + vars:
  6 + nameserver_timeout: 1
6 tasks: 7 tasks:
7 # make sure group exists 8 # make sure group exists
8 - name: make sure nameserver groups exist in inventory file 9 - name: make sure nameserver groups exist in inventory file
@@ -2,5 +2,20 @@ @@ -2,5 +2,20 @@
2 # playbook files for hosts resolv 2 # playbook files for hosts resolv
3 - hosts: docker 3 - hosts: docker
4 remote_user: root 4 remote_user: root
5 - roles:  
6 - - resolv 5 + vars:
  6 + nameserver_timeout: 1
  7 + tasks:
  8 + # make sure group exists
  9 + - name: make sure nameserver groups exist in inventory file
  10 + fail:
  11 + msg: "group {{ item }} not exist!"
  12 + when: item not in groups
  13 + with_items:
  14 + - nameservers
  15 +
  16 + - name: Configure resolv.conf
  17 + template:
  18 + src: resolv.conf.j2
  19 + dest: /etc/resolv.conf
  20 + mode: 0644
  21 +
1 -resolv  
2 -=========  
3 -  
4 -配置 `/etc/resolv.conf`  
5 -  
6 -  
7 -Requirements  
8 -------------  
9 -  
10 -`inventory` 文件中存在 `nameservers` (dns服务器地址)  
11 -  
12 -  
13 -Example Playbook  
14 -----------------  
15 -  
16 - ```yml  
17 -  
18 - - hosts: servers  
19 - roles:  
20 - - resolv  
21 -  
22 -```  
23 -  
24 -Author Information  
25 -------------------  
26 -  
27 -chunhua.zhang@yoho.cn  
1 ----  
2 -nameserver_timeout: 1  
1 ----  
2 -# handlers file for resolv  
1 -galaxy_info:  
2 - author: chunhua.zhang@yoho.cn  
3 - description: ansible roles for configure /etc/resolv.conf  
4 - company: yohobuy.com  
5 -  
6 - # If the issue tracker for your role is not on github, uncomment the  
7 - # next line and provide a value  
8 - # issue_tracker_url: http://example.com/issue/tracker  
9 -  
10 - # Some suggested licenses:  
11 - # - BSD (default)  
12 - # - MIT  
13 - # - GPLv2  
14 - # - GPLv3  
15 - # - Apache  
16 - # - CC-BY  
17 - license: license (GPLv2, CC-BY, etc)  
18 -  
19 - min_ansible_version: 1.2  
20 -  
21 - # If this a Container Enabled role, provide the minimum Ansible Container version.  
22 - # min_ansible_container_version:  
23 -  
24 - # Optionally specify the branch Galaxy will use when accessing the GitHub  
25 - # repo for this role. During role install, if no tags are available,  
26 - # Galaxy will use this branch. During import Galaxy will access files on  
27 - # this branch. If Travis integration is configured, only notifications for this  
28 - # branch will be accepted. Otherwise, in all cases, the repo's default branch  
29 - # (usually master) will be used.  
30 - #github_branch:  
31 -  
32 - #  
33 - # platforms is a list of platforms, and each platform has a name and a list of versions.  
34 - #  
35 - # platforms:  
36 - # - name: Fedora  
37 - # versions:  
38 - # - all  
39 - # - 25  
40 - # - name: SomePlatform  
41 - # versions:  
42 - # - all  
43 - # - 1.0  
44 - # - 7  
45 - # - 99.99  
46 -  
47 - galaxy_tags: []  
48 - # List tags for your role here, one per line. A tag is a keyword that describes  
49 - # and categorizes the role. Users find roles by searching for tags. Be sure to  
50 - # remove the '[]' above, if you add tags to this list.  
51 - #  
52 - # NOTE: A tag is limited to a single word comprised of alphanumeric characters.  
53 - # Maximum 20 tags per role.  
54 -  
55 -dependencies: []  
56 - # List your role dependencies here, one per line. Be sure to remove the '[]' above,  
57 - # if you add dependencies to this list.  
1 ----  
2 -# Configure resolv.conf  
3 -  
4 -  
5 -# make sure group exists  
6 -- name: make sure nameserver groups exist in inventory file  
7 - fail:  
8 - msg: "group {{ item }} not exist!"  
9 - when: item not in groups  
10 - with_items:  
11 - - nameservers  
12 -  
13 -  
14 -- name: Configure resolv.conf  
15 - template:  
16 - src: resolv.conf.j2  
17 - dest: /etc/resolv.conf  
18 - mode: 0644  
1 -# {{ ansible_managed }}  
2 -  
3 -  
4 -{% for i in groups['nameservers'] %}  
5 -nameserver {{ i }}  
6 -{% endfor %}  
7 -  
8 -{% if nameserver_timeout %}  
9 -options timeout: {{ nameserver_timeout }} rotate  
10 -{% endif %}  
1 ----  
2 -- hosts: localhost  
3 - remote_user: root  
4 - roles:  
5 - - resolv  
1 ----  
2 -# vars file for resolv