Browse Source

bootstrap

master
3moon 6 years ago
parent
commit
6ad48057e6
16 changed files with 119 additions and 1 deletions
  1. +10
    -1
      README.md
  2. +1
    -0
      bootstrap.retry
  3. +23
    -0
      bootstrap.yml
  4. +1
    -0
      inventory
  5. +4
    -0
      provision.yml
  6. +6
    -0
      roles/rpi-base/defaults/main.yml
  7. +3
    -0
      roles/rpi-base/handlers/main.yml
  8. +5
    -0
      roles/rpi-base/tasks/access.yml
  9. +10
    -0
      roles/rpi-base/tasks/hostname.yml
  10. +13
    -0
      roles/rpi-base/tasks/locale.yml
  11. +15
    -0
      roles/rpi-base/tasks/main.yml
  12. +13
    -0
      roles/rpi-base/tasks/user.yml
  13. +1
    -0
      roles/rpi-base/templates/etc/default/locale.j2
  14. +1
    -0
      roles/unifi/defaults/default.yml
  15. +7
    -0
      roles/unifi/tasks/main.yml
  16. +6
    -0
      vars/secrets.yml

+ 10
- 1
README.md View File

@ -1 +1,10 @@
# coming to a low-power ARM board far away from you, any day now
# coming to a low-power ARM board far away from you, any day now
## deps
ansible, `sshpass`
```sh
λ ~/git/comfy.lab/inf-aux
» ansible-playbook bootstrap.yml --extra-vars "unprepped=raspberrypi.lab.uncomfortably.online provision_hostname=aux" -i inventory
```

+ 1
- 0
bootstrap.retry View File

@ -0,0 +1 @@
aux.local

+ 23
- 0
bootstrap.yml View File

@ -0,0 +1,23 @@
- hosts: localhost
connection: local
tasks:
- add_host:
name: "{{ unprepped }}"
groups: unprepped
ansible_user: pi
ansible_password: raspberry
changed_when: false
- hosts: unprepped
vars_prompt:
- name: provision_hostname
prompt: hostname to provision with?
private: no
tasks:
- include_role:
name: rpi-base
vars:
new_hostname: "{{provision_hostname}}"
ssh_keys:
- "{{ lookup('file', 'keys/id_rsa.pub') }}"

+ 1
- 0
inventory View File

@ -0,0 +1 @@
aux.lab.uncomfortably.online ansible_user=pi

+ 4
- 0
provision.yml View File

@ -0,0 +1,4 @@
- hosts: aux.lab.uncomfortably.online
tasks:
- include_role:
name: unifi

+ 6
- 0
roles/rpi-base/defaults/main.yml View File

@ -0,0 +1,6 @@
#### locale ####
default_locale: 'en-US.UTF-8'
locales:
- 'en-US.UTF-8'
tz: America/Chicago

+ 3
- 0
roles/rpi-base/handlers/main.yml View File

@ -0,0 +1,3 @@
- name: locale-gen
shell: locale-gen
become: yes

+ 5
- 0
roles/rpi-base/tasks/access.yml View File

@ -0,0 +1,5 @@
- name: ACCESS | enable & start sshd
service:
name: ssh
state: started
enabled: yes

+ 10
- 0
roles/rpi-base/tasks/hostname.yml View File

@ -0,0 +1,10 @@
- name: HOSTNAME | set hostname
hostname:
name: '{{ new_hostname }}'
- name: HOSTNAME | replace hostname in /etc/hosts
replace:
path: /etc/hosts
regexp: '(127.0.1.1\s+).+(\s+.*)$'
replace: '\1{{new_hostname}}\2'

+ 13
- 0
roles/rpi-base/tasks/locale.yml View File

@ -0,0 +1,13 @@
- name: LOCALE | build locales
lineinfile:
path: /etc/locale.gen
regexp: '#\s*{{item}}'
line: '{{item}}'
state: present
with_items: "{{locales}}"
notify: locale-gen
- name: LOCALE | set default locale
template:
src: etc/default/locale.j2
dest: /etc/default/locale

+ 15
- 0
roles/rpi-base/tasks/main.yml View File

@ -0,0 +1,15 @@
- name: "############## IMPORT TASKS: hostname ##############"
import_tasks: hostname.yml
become: yes
- name: "############## IMPORT TASKS: locale ##############"
import_tasks: locale.yml
become: yes
- name: "############## IMPORT TASKS: access ##############"
import_tasks: access.yml
become: yes
- name: "############## IMPORT TASKS: user ##############"
import_tasks: user.yml
become: yes

+ 13
- 0
roles/rpi-base/tasks/user.yml View File

@ -0,0 +1,13 @@
# - name: USER | change password
# user:
# name: pi
# password: "{{ lookup('passwordstore', 'infra/machine/pi@' + ansible_hostname + ' create=true length=20')
# | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}"
- name: USER | add authorized SSH key(s)
authorized_key:
user: pi
state: present
key: "{{ lookup('file', item) }}"
with_fileglob:
- "keys/*.pub"

+ 1
- 0
roles/rpi-base/templates/etc/default/locale.j2 View File

@ -0,0 +1 @@
LOCALE="{{default_locale}}"

+ 1
- 0
roles/unifi/defaults/default.yml View File

@ -0,0 +1 @@
unifi_channel=stable

+ 7
- 0
roles/unifi/tasks/main.yml View File

@ -0,0 +1,7 @@
- apt_repository:
repo: "deb http://www.ubnt.com/downloads/unifi/debian {{unifi_channel}} ubiquiti"
state: present
- apt_key:
url: https://dl.ubnt.com/unifi/unifi-repo.gpg
state: present

+ 6
- 0
vars/secrets.yml View File

@ -0,0 +1,6 @@
$ANSIBLE_VAULT;1.1;AES256
36373864353634383162353562633637656532336132313664303736356664333166316363636132
3735623235646562373830336265646334316237383539630a373037653463393138663865616364
64666636336131626337646462636363613036366265646163373231633332663764633864653137
6537663231356235630a306461396237376466633039323434343366633139356264323862323938
65643437613533333366313831646231623335643832663836313164663032663432

Loading…
Cancel
Save