Add ansible-managed and nameserver roles
This commit is contained in:
parent
72569328d7
commit
0af5ca03d4
8 changed files with 95 additions and 0 deletions
28
roles/ansible-managed/.kitchen.yml
Normal file
28
roles/ansible-managed/.kitchen.yml
Normal 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
|
11
roles/ansible-managed/README.md
Normal file
11
roles/ansible-managed/README.md
Normal 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.
|
2
roles/ansible-managed/defaults/main.yml
Normal file
2
roles/ansible-managed/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
project_repository: "/!\\ No repository set, contact Evolix"
|
6
roles/ansible-managed/tasks/main.yml
Normal file
6
roles/ansible-managed/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Set message of the day
|
||||
template:
|
||||
src: motd.j2
|
||||
dest: /etc/motd
|
||||
force: yes
|
4
roles/ansible-managed/templates/motd.j2
Normal file
4
roles/ansible-managed/templates/motd.j2
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
SERVER MANAGED BY EVOLIX VIA ANSIBLE
|
||||
------------------------------------
|
||||
{{ project_repository | mandatory }}
|
4
roles/ansible-managed/tests/test.yml
Normal file
4
roles/ansible-managed/tests/test.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- hosts: test-kitchen
|
||||
roles:
|
||||
- role: ansible-managed
|
13
roles/nameserver/README.md
Normal file
13
roles/nameserver/README.md
Normal 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 ;
|
27
roles/nameserver/tasks/main.yml
Normal file
27
roles/nameserver/tasks/main.yml
Normal 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
|
Loading…
Reference in a new issue