mirror of
https://github.com/ruanbekker/rpi-ansible.git
synced 2025-04-20 01:11:38 +02:00
update to work in local mode
This commit is contained in:
parent
36a0a9996d
commit
0c2dbd7063
39
roles/common/tasks/loadconfig.yml
Normal file
39
roles/common/tasks/loadconfig.yml
Normal file
@ -0,0 +1,39 @@
|
||||
---
|
||||
# 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 }}"
|
@ -1,48 +1,5 @@
|
||||
---
|
||||
|
||||
# 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: self-identify based on mac address (local mode)
|
||||
set_fact:
|
||||
myhostname: "{{ macaddrs[my_macaddr] }}"
|
||||
when: inventory_hostname_short == 'localhost'
|
||||
tags:
|
||||
- raspi
|
||||
- sw
|
||||
- sshd
|
||||
- motd
|
||||
|
||||
- name: self-identify based on mac address (remote mode)
|
||||
set_fact:
|
||||
myhostname: "{{ inventory_hostname_short }}"
|
||||
when: "inventory_hostname_short != 'localhost'"
|
||||
tags:
|
||||
- raspi
|
||||
- sw
|
||||
- sshd
|
||||
- motd
|
||||
|
||||
- name: store system configuration
|
||||
set_fact:
|
||||
myconfig: "{{ hostvars[myhostname] }}"
|
||||
tags:
|
||||
- raspi
|
||||
- sw
|
||||
- sshd
|
||||
- motd
|
||||
|
||||
- debug:
|
||||
var: myconfig
|
||||
- include: loadconfig.yml
|
||||
|
||||
# Gather facts specific to the Raspberry Pi platform
|
||||
- include: raspi-facts.yml
|
||||
|
Loading…
x
Reference in New Issue
Block a user