-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding network role for setting network and dhcp settings via uci
- Loading branch information
Showing
5 changed files
with
122 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
openwrt-network | ||
================ | ||
|
||
network (and dhcp) config of your openwrt system. | ||
compare: [http://wiki.openwrt.org/doc/uci/network] and | ||
[http://wiki.openwrt.org/doc/uci/dhcp] | ||
|
||
Role Variables | ||
-------------- | ||
|
||
a bunch of per interface settings are all nested in a dict | ||
`network` and another `dhcp` one. the layout is a bit weird because | ||
i use with_subelements. look at the defaults and tasks directory. | ||
if you have a suggestion for how to do it more effectively without | ||
duplication, let me know! | ||
|
||
you may want to consider `hash_behaviour=merge` in your ansible.cfg | ||
|
||
Dependencies | ||
------------ | ||
|
||
[lefant.openwrt-uci] | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
[https://github.com/lefant/ansible-openwrt/blob/master/openwrt.yml] | ||
|
||
Requirements | ||
------------ | ||
|
||
must be kept minimal as this is supposed to run on openwrt embedded | ||
systems. in particular we try get by with plain POSIX shell, using | ||
neither python nor bash in any way. lua could be an option as that | ||
seems to be the openwrt scripting language of choice. | ||
|
||
License | ||
------- | ||
|
||
BSD | ||
|
||
Author Information | ||
------------------ | ||
|
||
Jan Wagner [http://blog.waja.info/] | ||
|
||
|
||
|
||
[https://github.com/lefant/ansible-openwrt/blob/master/openwrt.yml]: https://github.com/lefant/ansible-openwrt/blob/master/openwrt.yml | ||
[http://wiki.openwrt.org/doc/uci/network]: http://wiki.openwrt.org/doc/uci/network | ||
[http://wiki.openwrt.org/doc/uci/dhcp]: http://wiki.openwrt.org/doc/uci/dhcp | ||
[lefant.openwrt-uci]: https://galaxy.ansible.com/list#/roles/1645 | ||
[http://e.lefant.net/]: http://e.lefant.net/ |
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,20 @@ | ||
--- | ||
# defaults file for openwrt-network | ||
network: | ||
- key: ipaddr | ||
value: 192.168.1.1 | ||
ifaces: [lan] | ||
- key: netmask | ||
value: 255.255.255.0 | ||
ifaces: [lan] | ||
- key: gateway | ||
value: "" | ||
ifaces: [lan] | ||
- key: dns | ||
value: "" | ||
ifaces: [lan] | ||
|
||
dhcp: | ||
- key: ignore | ||
value: "" | ||
ifaces: [lan] |
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,14 @@ | ||
--- | ||
# handlers file for openwrt-network | ||
- name: reload network | ||
raw: /etc/init.d/network reload | ||
|
||
- name: restart network | ||
raw: /etc/init.d/network restart | ||
|
||
- name: reload dhcp | ||
raw: /etc/init.d/dnsmasq reload | ||
|
||
- name: restart dhcp | ||
raw: /etc/init.d/dnsmasq restart | ||
|
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,15 @@ | ||
--- | ||
galaxy_info: | ||
author: Jan Wagner | ||
description: network config of your openwrt system. | ||
license: BSD | ||
min_ansible_version: 1.7 | ||
platforms: [] | ||
# - Openwrt | ||
# versions: | ||
# - 14.07 | ||
categories: | ||
- system | ||
- network | ||
dependencies: | ||
- { role: lefant.openwrt-uci } |
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,20 @@ | ||
--- | ||
# tasks file for openwrt-network | ||
- name: apply network uci settings | ||
uci: command=set key="network.{{ item.1 }}.{{ item.0.key }}" value="{{ item.0.value }}" | ||
with_subelements: | ||
- network | ||
- ifaces | ||
notify: | ||
- uci commit | ||
- restart network | ||
|
||
- name: apply dhcp uci settings | ||
uci: command=set key="dhcp.{{ item.1 }}.{{ item.0.key }}" value="{{ item.0.value }}" | ||
with_subelements: | ||
- dhcp | ||
- ifaces | ||
notify: | ||
- uci commit | ||
- restart dhcp | ||
|