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/main.yml

45 lines
1.1 KiB

7 years ago
---
# Basic hostname setup
- name: Get MAC address
debug: msg="{{ hostvars[inventory_hostname].ansible_default_ipv4.macaddress }}"
- name: store MAC address
set_fact:
my_macaddr: "{{ hostvars[inventory_hostname].ansible_default_ipv4.macaddress }}"
7 years ago
- name: set hostname
hostname: name={{ macaddrs[my_macaddr].hostname }}
when: my_macaddr in macaddrs
7 years ago
- name: update /etc/hosts with new hostname
lineinfile:
dest=/etc/hosts
regexp="^{{ ansible_default_ipv4.address }}"
line="{{ ansible_default_ipv4.address }}{{'\t'}}{{ macaddrs[my_macaddr].hostname }}.local{{'\t'}}{{ macaddrs[my_macaddr].hostname }}"
7 years ago
state=present
when: my_macaddr in macaddrs
7 years ago
- name: get rid of default 127.0.1.1 binding
lineinfile:
dest=/etc/hosts
regexp="^127.0.1.1"
state=absent
# Set timezone
- name: set /etc/timezone
7 years ago
copy: src=etc/timezone
dest=/etc/timezone
owner=root
group=root
mode=0644
backup=yes
notify:
- changed timezone
# Other tasks
- include: software.yml
- include: users.yml
- include: hardware.yml