-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from dresden-weekly/develop
1.0 release
- Loading branch information
Showing
10 changed files
with
271 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
--- | ||
- name: restart | ||
- name: network all interfaces changed | ||
service: | ||
name: "{{ network_service }}" | ||
state: restarted | ||
when: network_allow_service_restart | ||
register: network_service_restart_result | ||
|
||
- name: network restart interface service | ||
# schema: network_configuration_result.results | ||
# = [ { "item": [ <device>, [<config>, ...] ], ... }, ... ] | ||
service: | ||
name: "{{ network_service }}" | ||
state: restarted | ||
arguments: "INTERFACE={{ item.item.0 }}" | ||
when: > | ||
(network_service_restart_result is undefined or not network_service_restart_result.changed) | ||
and ('service' == network_restart_method) | ||
and item.changed | ||
and item.item.1.0.auto | default(true) | ||
with_items: "{{network_configuration_result.results | default([])}}" | ||
|
||
- name: network restart interface command | ||
include: 'exec_restart_command.yml' | ||
vars: | ||
device: "{{ item.item.0 }}" | ||
configs: "{{ item.item.1 }}" | ||
when: > | ||
(network_service_restart_result is undefined or not network_service_restart_result.changed) | ||
and (network_restart_method in network_interface_restart_commands) | ||
and item.changed | ||
and item.item.1.0.auto | default(true) | ||
with_items: "{{network_configuration_result.results | default([])}}" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: create directory | ||
file: | ||
path: "{{ network_interface_path }}" | ||
state: directory | ||
|
||
- name: all interfaces | ||
template: | ||
src: all_interfaces.j2 | ||
dest: "{{ network_all_interfaces_path }}" | ||
notify: | ||
- network all interfaces changed |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- name: network restart interface command | ||
shell: > | ||
{{ network_interface_restart_commands[ network_restart_method ] }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,26 @@ | ||
--- | ||
- name: create directory | ||
file: | ||
path: "{{ network_interface_path }}" | ||
state: directory | ||
when: network_interfaces | ||
|
||
- name: all interfaces | ||
template: | ||
src: all_interfaces.j2 | ||
dest: "{{ network_all_interfaces_path }}" | ||
notify: restart | ||
when: network_interfaces | ||
- name: ensure basic networking tools are installed | ||
apt: | ||
pkg: "{{ item }}" | ||
state: present | ||
update_cache: yes | ||
cache_valid_time: 86400 | ||
with_items: | ||
- vlan | ||
|
||
- name: list network interfaces | ||
command: "find {{ network_interface_path }} -type f" | ||
changed_when: no | ||
- include: all_interfaces.yml | ||
when: network_interfaces | ||
register: network_existing_files | ||
|
||
- name: configurations | ||
template: | ||
src: device.j2 | ||
dest: "{{ network_interface_path }}/device-{{ item.device }}-{{ item.family | default('inet') }}" | ||
with_items: network_interfaces | ||
dest: "{{ network_interface_path }}/device-{{ item.0 }}" | ||
with_items: | ||
- "{{network_interfaces | default([]) | groupby('device') }}" | ||
register: network_configuration_result | ||
notify: | ||
- network restart interface service | ||
- network restart interface command | ||
|
||
- name: configured files | ||
set_fact: | ||
network_configured_files: > | ||
[{% for item in network_configuration_result.results | default([]) -%} | ||
u"{{ item.dest | default(item.path) }}" | ||
{{ '' if loop.last else ',' }} | ||
{%- endfor %}] | ||
- name: remove configurations | ||
file: | ||
dest: "{{ item }}" | ||
state: absent | ||
when: > | ||
network_manage_devices | ||
and (item not in network_configured_files) | ||
with_items: network_existing_files.stdout_lines | default([]) | ||
|
||
- name: restart devices | ||
service: | ||
name: "{{ network_service }}" | ||
state: restarted | ||
arguments: "INTERFACE={{ item.0 }}" | ||
when: > | ||
(0 != item.1 | selectattr('changed') | list | length) | ||
and ((0 != item.1 | selectattr('item.auto', 'undefined') | list | length) | ||
or (true in item.1 | selectattr('item.auto') | list) | ||
) | ||
with_items: network_configuration_result.results | default([]) | groupby('item.device') | ||
- include: manage_devices.yml | ||
when: network_manage_devices |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- name: list existing files | ||
command: "find {{ network_interface_path }} -type f" | ||
changed_when: no | ||
when: network_interfaces | ||
register: network_existing_files | ||
|
||
# depending on change the result stores dest or path | ||
- name: configured files | ||
set_fact: | ||
network_configured_files: > | ||
[{% for item in network_configuration_result.results | default([]) -%} | ||
u"{{ item.dest | default(item.path) }}" | ||
{{ '' if loop.last else ',' }} | ||
{%- endfor %}] | ||
- name: remove configurations | ||
file: | ||
dest: "{{ item }}" | ||
state: absent | ||
when: item not in network_configured_files | ||
with_items: "{{network_existing_files.stdout_lines | default([])}}" |
Oops, something went wrong.