---
# handlers file for setup

#
#	Set hostname when /etc/hostsname is updated
#
- name: Set hostname
  shell: "hostname $(cat /etc/hostname)"

#
#	Run update-ca-certificates
#
- name: update-ca-certificates
  shell: "update-ca-certificates"

#
#	Make sure init script is run
#
- name: update rc
  shell: "update-rc.d -f ttn-pkt-forwarder remove; update-rc.d ttn-pkt-forwarder defaults 95 30"
  
#
#	Restart the packet forwarder
#
- name: restart ttn-pkt-forwarder
  service: name=ttn-pkt-forwarder state=restarted

#
#       Restart ntpd
#
- name: restart ntpd
  service: name=ntpd state=restarted

#
#       Restart ssh_tunnel
#
- name: restart ssh_tunnel
  service: name=ssh_tunnel state=restarted

#
#	Restart sshd after config changes
#
- name: Restart ssh
  service: name=sshd state=restarted
  async: 1
  ignore_errors: true

#
#	Remind 
#
- name: interface reboot
  debug:
    msg: Interface configuration changed, remember to reboot

---
# handlers file for setup

#
#	Set hostname when /etc/hostsname is updated
#
- name: Set hostname
  shell: "hostname -F /etc/hostname"

#
#	Run update-ca-certificates
#
- name: update-ca-certificates
  shell: "update-ca-certificates"

#
#	Make sure init script is run
#
- name: update rc
  shell: "update-rc.d -f ttn-pkt-forwarder remove; update-rc.d ttn-pkt-forwarder defaults 95 30"
  
#
#	Restart the packet forwarder
#
- name: restart ttn-pkt-forwarder
  service: name=ttn-pkt-forwarder state=restarted

#
#       Restart ntpd
#
- name: restart ntpd
  service: name=ntpd state=restarted

#
#       Restart ssh_tunnel
#
- name: restart ssh_tunnel
  service: name=ssh_tunnel state=restarted

#
#	Restart sshd after config changes
#
- name: Restart ssh
  service: name=sshd state=restarted
  async: 1
  ignore_errors: true

#
#	Remind 
#
- name: interface reboot
  debug:
    msg: Interface configuration changed, remember to reboot

Use -F option to hostname to set from a file
Use -F option to hostname to set from a file
