summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chaos-at-home/openwrt-deploy.yml9
-rw-r--r--common/cloud-install.yml2
-rw-r--r--common/iso-install.yml2
-rw-r--r--common/openwrt-deploy.yml20
-rw-r--r--common/usb-install.yml2
-rw-r--r--common/vm-deploy.yml3
-rw-r--r--common/vm-install.yml2
-rw-r--r--dan/openwrt-deploy.yml9
-rwxr-xr-xdeploy.sh4
-rwxr-xr-xinstall.sh4
-rw-r--r--inventory/hosts.ini21
l---------openwrt-deploy.sh1
-rw-r--r--roles/openwrt/deploy/action_plugins/openwrt_sysupgrade.py57
-rw-r--r--roles/openwrt/deploy/tasks/main.yml5
-rw-r--r--spreadspace/openwrt-deploy.yml9
15 files changed, 142 insertions, 8 deletions
diff --git a/chaos-at-home/openwrt-deploy.yml b/chaos-at-home/openwrt-deploy.yml
new file mode 100644
index 00000000..2832d6ed
--- /dev/null
+++ b/chaos-at-home/openwrt-deploy.yml
@@ -0,0 +1,9 @@
+---
+- name: generate os image
+ hosts: "{{ install_hostname }}"
+ connection: local
+ gather_facts: no
+ roles:
+ - role: openwrt/image
+
+- import_playbook: ../common/openwrt-deploy.yml
diff --git a/common/cloud-install.yml b/common/cloud-install.yml
index 506ad2bc..f0a9870d 100644
--- a/common/cloud-install.yml
+++ b/common/cloud-install.yml
@@ -15,6 +15,8 @@
set_fact:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no{% if install_jumphost is defined %} -o 'ProxyCommand ssh -q -a {{ install_jumphost }} -W %h:%p'{% endif %}"
+ - name: remove host-keys from ssh known-hosts
+ local_action: command "{{ (inventory_dir, '../remove-known-host.sh') | path_join | realpath }}" "{{ install_hostname }}"
- name: clear all gathered facts
meta: clear_facts
- name: wait for host to start up
diff --git a/common/iso-install.yml b/common/iso-install.yml
index 796ae0d9..3088b107 100644
--- a/common/iso-install.yml
+++ b/common/iso-install.yml
@@ -47,6 +47,8 @@
set_fact:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no{% if install_jumphost is defined %} -o 'ProxyCommand ssh -q -a {{ install_jumphost }} -W %h:%p'{% endif %}"
+ - name: remove host-keys from ssh known-hosts
+ local_action: command "{{ (inventory_dir, '../remove-known-host.sh') | path_join | realpath }}" "{{ install_hostname }}"
- name: clear all gathered facts
meta: clear_facts
- name: wait for host to start up
diff --git a/common/openwrt-deploy.yml b/common/openwrt-deploy.yml
new file mode 100644
index 00000000..1ef70a5e
--- /dev/null
+++ b/common/openwrt-deploy.yml
@@ -0,0 +1,20 @@
+---
+- name: preparations and sanity checks
+ hosts: "{{ install_hostname }}"
+ connection: local
+ gather_facts: no
+ tasks:
+ - name: check if there is only one output image
+ fail:
+ msg: "the output_images variable must only contain a single image"
+ when:
+ - (output_images | length) != 1
+
+- name: deploy openwrt image
+ hosts: "{{ install_hostname }}"
+ gather_facts: no
+ roles:
+ - role: openwrt/deploy
+ post_tasks:
+ - name: remove host-keys from ssh known-hosts
+ local_action: command "{{ (inventory_dir, '../remove-known-host.sh') | path_join | realpath }}" "{{ install_hostname }}"
diff --git a/common/usb-install.yml b/common/usb-install.yml
index a7bbe012..a909e679 100644
--- a/common/usb-install.yml
+++ b/common/usb-install.yml
@@ -36,6 +36,8 @@
set_fact:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no{% if install_jumphost is defined %} -o 'ProxyCommand ssh -q -a {{ install_jumphost }} -W %h:%p'{% endif %}"
+ - name: remove host-keys from ssh known-hosts
+ local_action: command "{{ (inventory_dir, '../remove-known-host.sh') | path_join | realpath }}" "{{ install_hostname }}"
- name: clear all gathered facts
meta: clear_facts
- name: wait for host to start up
diff --git a/common/vm-deploy.yml b/common/vm-deploy.yml
index 5368df3e..8f4aa926 100644
--- a/common/vm-deploy.yml
+++ b/common/vm-deploy.yml
@@ -38,3 +38,6 @@
gather_facts: no
roles:
- role: vm/guest/deploy
+ post_tasks:
+ - name: remove host-keys from ssh known-hosts
+ local_action: command "{{ (inventory_dir, '../remove-known-host.sh') | path_join | realpath }}" "{{ install_hostname }}"
diff --git a/common/vm-install.yml b/common/vm-install.yml
index 90b08c56..cffde0c2 100644
--- a/common/vm-install.yml
+++ b/common/vm-install.yml
@@ -34,6 +34,8 @@
set_fact:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no{% if install_jumphost is defined %} -o 'ProxyCommand ssh -q -a {{ install_jumphost }} -W %h:%p'{% endif %}"
+ - name: remove host-keys from ssh known-hosts
+ local_action: command "{{ (inventory_dir, '../remove-known-host.sh') | path_join | realpath }}" "{{ install_hostname }}"
- name: clear all gathered facts
meta: clear_facts
- name: wait for host to start up
diff --git a/dan/openwrt-deploy.yml b/dan/openwrt-deploy.yml
new file mode 100644
index 00000000..2832d6ed
--- /dev/null
+++ b/dan/openwrt-deploy.yml
@@ -0,0 +1,9 @@
+---
+- name: generate os image
+ hosts: "{{ install_hostname }}"
+ connection: local
+ gather_facts: no
+ roles:
+ - role: openwrt/image
+
+- import_playbook: ../common/openwrt-deploy.yml
diff --git a/deploy.sh b/deploy.sh
index c073283f..800fd52e 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -17,10 +17,6 @@ vault_environment__set "$env_group" || exit 1
echo "deploying $name with $distro/$codename in environment '$env_group'"
echo ""
-echo "########## clearing old ssh host keys #########"
-remove_known_hosts "$name"
-echo ""
-
echo "########## removing cached facts #########"
rm -f ".cache/facts/$name"
echo ""
diff --git a/install.sh b/install.sh
index 68e06553..52320c58 100755
--- a/install.sh
+++ b/install.sh
@@ -17,10 +17,6 @@ vault_environment__set "$env_group" || exit 1
echo "installing $name with $distro/$codename in environment '$env_group'"
echo ""
-echo "########## clearing old ssh host keys #########"
-remove_known_hosts "$name"
-echo ""
-
echo "########## removing cached facts #########"
rm -f ".cache/facts/$name"
echo ""
diff --git a/inventory/hosts.ini b/inventory/hosts.ini
index bed5319e..9d555778 100644
--- a/inventory/hosts.ini
+++ b/inventory/hosts.ini
@@ -288,6 +288,27 @@ emc-0[1:3]
# host categories
## OS
+[openwrt:vars]
+ansible_ssh_transfer_method=scp
+
+[openwrt]
+ch-router
+ch-alix1d
+ch-testvm-openwrt
+mz-ap
+mz-router
+glt-gw-r3
+glt-gw-tug
+ele-router
+ele-uhrturm
+ele-orpheum
+ele-tub
+[openwrt:children]
+accesspoints
+chaos-at-home-sensors
+ups
+
+
[dellos6:children]
chaos-at-home-switches
diff --git a/openwrt-deploy.sh b/openwrt-deploy.sh
new file mode 120000
index 00000000..91c11375
--- /dev/null
+++ b/openwrt-deploy.sh
@@ -0,0 +1 @@
+deploy.sh \ No newline at end of file
diff --git a/roles/openwrt/deploy/action_plugins/openwrt_sysupgrade.py b/roles/openwrt/deploy/action_plugins/openwrt_sysupgrade.py
new file mode 100644
index 00000000..16772937
--- /dev/null
+++ b/roles/openwrt/deploy/action_plugins/openwrt_sysupgrade.py
@@ -0,0 +1,57 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import os
+
+from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionFail, AnsibleActionSkip, AnsibleConnectionFailure
+from ansible.module_utils._text import to_native
+from ansible.plugins.action import ActionBase
+
+
+class ActionModule(ActionBase):
+ TRANSFERS_FILES = True
+
+ def run(self, tmp=None, task_vars=None):
+ if task_vars is None:
+ task_vars = dict()
+
+ if self._task.environment and any(self._task.environment):
+ self._display.warning('openwrt_sysupgrade module does not support the environment keyword')
+
+ result = super(ActionModule, self).run(tmp, task_vars)
+ del tmp # tmp no longer has any effect
+ self._cleanup_remote_tmp = False
+
+ try:
+ if self._play_context.check_mode:
+ raise AnsibleActionSkip('Check mode is not supported for this task.')
+
+ result['changed'] = True
+
+ try:
+ image = to_native(self._task.args.get('image', ''), errors='surrogate_or_strict')
+ image = self._loader.get_real_file(self._find_needle('files', image), decrypt=False)
+ except AnsibleError as e:
+ raise AnsibleActionFail(to_native(e))
+
+ tmp_img = self._connection._shell.join_path(self._connection._shell.tmpdir, os.path.basename(image))
+ self._transfer_file(image, tmp_img)
+ self._fixup_perms2((self._connection._shell.tmpdir, tmp_img), execute=False)
+
+ args = to_native(self._task.args.get('args', ''), errors='surrogate_or_strict')
+
+ script_cmd = ' '.join(['sysupgrade', args, tmp_img])
+ script_cmd = self._connection._shell.wrap_for_exec(script_cmd)
+
+ try:
+ result.update(self._low_level_execute_command(cmd=script_cmd))
+ except AnsibleConnectionFailure as e:
+ result['rc'] = 0
+
+ if 'rc' in result and result['rc'] != 0:
+ raise AnsibleActionFail('non-zero return code')
+
+ except AnsibleAction as e:
+ result.update(e.result)
+
+ return result
diff --git a/roles/openwrt/deploy/tasks/main.yml b/roles/openwrt/deploy/tasks/main.yml
new file mode 100644
index 00000000..06fb28ad
--- /dev/null
+++ b/roles/openwrt/deploy/tasks/main.yml
@@ -0,0 +1,5 @@
+---
+- name: copy image and run sysupgrade
+ openwrt_sysupgrade:
+ image: "{{ output_images | first }}"
+ args: -n
diff --git a/spreadspace/openwrt-deploy.yml b/spreadspace/openwrt-deploy.yml
new file mode 100644
index 00000000..2832d6ed
--- /dev/null
+++ b/spreadspace/openwrt-deploy.yml
@@ -0,0 +1,9 @@
+---
+- name: generate os image
+ hosts: "{{ install_hostname }}"
+ connection: local
+ gather_facts: no
+ roles:
+ - role: openwrt/image
+
+- import_playbook: ../common/openwrt-deploy.yml