Ansible playbook for configuring a fresh install of Raspbian
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rpi-ansible/roles/common/tasks/loadconfig.yml

39 lines
916 B

---
# Self identify and load config - this allows the playbook to run on either
# localhost or a remote host
- name: store MAC address for eth0
set_fact:
my_macaddr: "{{ hostvars[inventory_hostname].ansible_eth0.macaddress }}"
when: inventory_hostname == 'localhost'
tags:
- raspi
- sw
- sshd
- motd
- name: load raspberry pi configuration (local mode)
include_vars:
file: "../../../host_vars/{{ macaddrs[my_macaddr] }}"
name: myconfig
when: inventory_hostname_short == 'localhost'
tags:
- raspi
- sw
- sshd
- motd
- name: load raspberry pi configuration (remote mode)
set_fact:
myconfig: "{{ hostvars[inventory_hostname_short] }}"
when: "inventory_hostname_short != 'localhost'"
tags:
- raspi
- sw
- sshd
- motd
- debug:
msg: "loaded configuration for {{ myconfig.hostname }}"
- assert:
that: "{{ myconfig|length > 0 }}"