Authored by Your Name

替换resolv role

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