Add ansible-managed and nameserver roles

This commit is contained in:
Jérémy Lecour 2017-10-09 14:59:49 +02:00 committed by Jérémy Lecour
parent 72569328d7
commit 0af5ca03d4
8 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,28 @@
---
driver:
name: docker
privileged: true
use_sudo: false
provisioner:
name: ansible_playbook
hosts: test-kitchen
roles_path: ../
ansible_verbose: true
require_ansible_source: false
require_chef_for_busser: false
idempotency_test: true
platforms:
- name: debian
driver_config:
image: evolix/ansible:2.2.1
suites:
- name: default
provisioner:
name: ansible_playbook
playbook: ./tests/test.yml
transport:
max_ssh_sessions: 6

View File

@ -0,0 +1,11 @@
# ansible-managed
Set some indications that the server is managed by Ansible and extra care yshould be given not no mess with it manually.
## Tasks
Everything is in the `tasks/main.yml` file.
## Available variables
* `project_repository` : project URL for the repository.

View File

@ -0,0 +1,2 @@
---
project_repository: "/!\\ No repository set, contact Evolix"

View File

@ -0,0 +1,6 @@
---
- name: Set message of the day
template:
src: motd.j2
dest: /etc/motd
force: yes

View File

@ -0,0 +1,4 @@
SERVER MANAGED BY EVOLIX VIA ANSIBLE
------------------------------------
{{ project_repository | mandatory }}

View File

@ -0,0 +1,4 @@
---
- hosts: test-kitchen
roles:
- role: ansible-managed

View File

@ -0,0 +1,13 @@
# nameserver
Set nameserver in /etc/resolv.conf.
## Tasks
Everything is in the `tasks/main.yml` file.
## Available variables
Main variables are :
* `nameservers` : list of IP addresses of DNS servers ;

View File

@ -0,0 +1,27 @@
---
- name: Get actual nameserver
shell: grep nameserver /etc/resolv.conf | awk '{ print $2 }'
register: grep_nameserver
check_mode: no
changed_when: false
tags:
- nameserver
- name: Set nameserver
lineinfile:
dest: /etc/resolv.conf
line: "nameserver {{ item }}"
state: present
with_items: "{{ nameservers }}"
tags:
- nameserver
- name: Unset others nameserver
lineinfile:
dest: /etc/resolv.conf
line: "nameserver {{ item }}"
state: absent
with_items: "{{ grep_nameserver.stdout_lines }}"
when: item not in nameservers
tags:
- nameserver