mirror of
				https://github.com/ruanbekker/rpi-ansible.git
				synced 2025-11-04 09:21:13 +01:00 
			
		
		
		
	added table of rpi hardware revs to dress up motd
This commit is contained in:
		
							parent
							
								
									8bb39632fd
								
							
						
					
					
						commit
						50e1b1ec19
					
				@ -12,6 +12,7 @@
 | 
			
		||||
    - raspi
 | 
			
		||||
    - sw
 | 
			
		||||
    - sshd
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
- name: store MAC address
 | 
			
		||||
  set_fact:
 | 
			
		||||
@ -20,6 +21,7 @@
 | 
			
		||||
    - raspi
 | 
			
		||||
    - sw
 | 
			
		||||
    - sshd
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
- name: store system configuration
 | 
			
		||||
  set_fact:
 | 
			
		||||
@ -28,6 +30,7 @@
 | 
			
		||||
    - raspi
 | 
			
		||||
    - sw
 | 
			
		||||
    - sshd
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
- name: set hostname
 | 
			
		||||
  shell: "raspi-config nonint do_hostname {{ myconfig.hostname }}"
 | 
			
		||||
@ -90,13 +93,21 @@
 | 
			
		||||
  when: "'darshan_dev' in myconfig and myconfig.darshan_dev"
 | 
			
		||||
 | 
			
		||||
# Install motd
 | 
			
		||||
- name: install MOTD
 | 
			
		||||
- name: load Raspberry Pi hardware history
 | 
			
		||||
  include_vars:
 | 
			
		||||
    file: vars/raspi-models.yml
 | 
			
		||||
  tags: 
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
- name: install motd
 | 
			
		||||
  template:
 | 
			
		||||
    src: etc/motd
 | 
			
		||||
    dest: /etc/motd
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: "0644"
 | 
			
		||||
  tags: 
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
# Configure firewall
 | 
			
		||||
- name: allow SSH through UFW
 | 
			
		||||
 | 
			
		||||
@ -191,7 +191,16 @@
 | 
			
		||||
  tags:
 | 
			
		||||
    - raspi
 | 
			
		||||
 | 
			
		||||
- name: set raspi-config facts
 | 
			
		||||
- name: get Raspberry Pi revision info
 | 
			
		||||
  command: awk '/^Revision/ {print $3}' /proc/cpuinfo
 | 
			
		||||
  register: raspi_rev
 | 
			
		||||
  changed_when: False
 | 
			
		||||
  check_mode: no
 | 
			
		||||
  tags:
 | 
			
		||||
    - raspi
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
- name: set raspi-config facts (all)
 | 
			
		||||
  set_fact:
 | 
			
		||||
    raspi_type: "{{ raspi_type.stdout }}"
 | 
			
		||||
    raspi_hostname: "{{ raspi_hostname.stdout }}"
 | 
			
		||||
@ -216,6 +225,15 @@
 | 
			
		||||
    raspi_gpu_mem_256: "{{ raspi_gpu_mem_256.stdout }}"
 | 
			
		||||
    raspi_gpu_mem_512: "{{ raspi_gpu_mem_512.stdout }}"
 | 
			
		||||
    raspi_gpu_mem_1024: "{{ raspi_gpu_mem_1024.stdout }}"
 | 
			
		||||
    raspi_rev: "{{ raspi_rev.stdout }}"
 | 
			
		||||
  check_mode: no
 | 
			
		||||
  tags:
 | 
			
		||||
    - raspi
 | 
			
		||||
 | 
			
		||||
- name: set raspi-config facts (for motd)
 | 
			
		||||
  set_fact:
 | 
			
		||||
    raspi_rev: "{{ raspi_rev.stdout }}"
 | 
			
		||||
  check_mode: no
 | 
			
		||||
  tags:
 | 
			
		||||
    - raspi
 | 
			
		||||
    - motd
 | 
			
		||||
 | 
			
		||||
@ -1,20 +1,15 @@
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
{% if myconfig.hostname == "cloverdale" %}
 | 
			
		||||
{% if myconfig.hostname == "some_specific_hostname" %}
 | 
			
		||||
{% else %}
 | 
			
		||||
     .~~.   .~~.
 | 
			
		||||
    '. \ ' ' / .'
 | 
			
		||||
     .~ .~~~..~.
 | 
			
		||||
    : .~.'~'.~. :     {{ myconfig.hostname }}
 | 
			
		||||
   ~ (   ) (   ) ~
 | 
			
		||||
  ( : '~'.~.'~' : )   {{ ansible_processor_count }} core{% if ansible_processor_count > 1 %}s{% endif %}, {{ ansible_memtotal_mb }} MB RAM
 | 
			
		||||
   ~ (   ) (   ) ~    Raspberry Pi {% if raspi_rev in raspi_models %}{{ raspi_models[raspi_rev].model }}{% else %}Revision {{ raspi_rev }}{% endif %} 
 | 
			
		||||
  ( : '~'.~.'~' : )   {{ ansible_processor_count }} core{% if ansible_processor_count > 1 %}s{% endif %}, {% if raspi_rev in raspi_models %}{{ raspi_models[raspi_rev].mem }}{% else %}{{ ansible_memtotal_mb }} MB{% endif %} RAM
 | 
			
		||||
   ~ .~ (   ) ~. ~    {{ ansible_lsb.description }}
 | 
			
		||||
    (  : '~' :  ) 
 | 
			
		||||
     '~ .~~~. ~'
 | 
			
		||||
         '~'
 | 
			
		||||
{% else %}
 | 
			
		||||
{{ myconfig.hostname }}
 | 
			
		||||
{{ ansible_processor_count }} core{% if ansible_processor_count > 1 %}s
 | 
			
		||||
{% endif %}
 | 
			
		||||
{{ ansible_memtotal_mb }} MB RAM
 | 
			
		||||
{{ ansible_lsb.description }}
 | 
			
		||||
{% endif %}
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										240
									
								
								roles/common/vars/raspi-models.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										240
									
								
								roles/common/vars/raspi-models.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,240 @@
 | 
			
		||||
---
 | 
			
		||||
# Taken from https://elinux.org/RPi_HardwareHistory
 | 
			
		||||
# Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
 | 
			
		||||
raspi_models:
 | 
			
		||||
  Beta:
 | 
			
		||||
    release: "Q1 2012"
 | 
			
		||||
    model: "B (Beta)"
 | 
			
		||||
    pcb_rev: "?"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "Beta Board"
 | 
			
		||||
  0002:
 | 
			
		||||
    release: "Q1 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
  0003:
 | 
			
		||||
    release: "Q3 2012"
 | 
			
		||||
    model: "B (ECN0001)"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "Fuses mod and D14 removed"
 | 
			
		||||
  0004:
 | 
			
		||||
    release: "Q3 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
  0005:
 | 
			
		||||
    release: "Q4 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "(Mfg by Qisda)"
 | 
			
		||||
  0006:
 | 
			
		||||
    release: "Q4 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "(Mfg by Egoman)"
 | 
			
		||||
  0007:
 | 
			
		||||
    release: "Q1 2013"
 | 
			
		||||
    model: "A"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "(Mfg by Egoman)"
 | 
			
		||||
  0008:
 | 
			
		||||
    release: "Q1 2013"
 | 
			
		||||
    model: "A"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  0009:
 | 
			
		||||
    release: "Q1 2013"
 | 
			
		||||
    model: "A"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "(Mfg by Qisda)"
 | 
			
		||||
  000d:
 | 
			
		||||
    release: "Q4 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Egoman)"
 | 
			
		||||
  000e:
 | 
			
		||||
    release: "Q4 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  000f:
 | 
			
		||||
    release: "Q4 2012"
 | 
			
		||||
    model: "B"
 | 
			
		||||
    pcb_rev: "2.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Qisda)"
 | 
			
		||||
  0010:
 | 
			
		||||
    release: "Q3 2014"
 | 
			
		||||
    model: "B+"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  0011:
 | 
			
		||||
    release: "Q2 2014"
 | 
			
		||||
    model: "Compute Module 1"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  0012:
 | 
			
		||||
    release: "Q4 2014"
 | 
			
		||||
    model: "A+"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "256 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  0013:
 | 
			
		||||
    release: "Q1 2015"
 | 
			
		||||
    model: "B+"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  0014:
 | 
			
		||||
    release: "Q2 2014"
 | 
			
		||||
    model: "Compute Module 1"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  0015:
 | 
			
		||||
    release: "?"
 | 
			
		||||
    model: "A+"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "256 MB / 512 MB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  a01040:
 | 
			
		||||
    release: "Unknown"
 | 
			
		||||
    model: "2 Model B"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a01041:
 | 
			
		||||
    release: "Q1 2015"
 | 
			
		||||
    model: "2 Model B"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a21041:
 | 
			
		||||
    release: "Q1 2015"
 | 
			
		||||
    model: "2 Model B"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  a22042:
 | 
			
		||||
    release: "Q3 2016"
 | 
			
		||||
    model: "2 Model B (with BCM2837)"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  900021:
 | 
			
		||||
    release: "Q3 2016"
 | 
			
		||||
    model: "A+"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  900032:
 | 
			
		||||
    release: "Q2 2016?"
 | 
			
		||||
    model: "B+"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  900092:
 | 
			
		||||
    release: "Q4 2015"
 | 
			
		||||
    model: "Zero"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  900093:
 | 
			
		||||
    release: "Q2 2016"
 | 
			
		||||
    model: "Zero"
 | 
			
		||||
    pcb_rev: "1.3"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  920093:
 | 
			
		||||
    release: "Q4 2016?"
 | 
			
		||||
    model: "Zero"
 | 
			
		||||
    pcb_rev: "1.3"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  9000c1:
 | 
			
		||||
    release: "Q1 2017"
 | 
			
		||||
    model: "Zero W"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a02082:
 | 
			
		||||
    release: "Q1 2016"
 | 
			
		||||
    model: "3 Model B"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a020a0:
 | 
			
		||||
    release: "Q1 2017"
 | 
			
		||||
    model: "Compute Module 3 (and CM3 Lite)"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a22082:
 | 
			
		||||
    release: "Q1 2016"
 | 
			
		||||
    model: "3 Model B"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Embest)"
 | 
			
		||||
  a32082:
 | 
			
		||||
    release: "Q4 2016"
 | 
			
		||||
    model: "3 Model B"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony Japan)"
 | 
			
		||||
  a020d3:
 | 
			
		||||
    release: "Q1 2018"
 | 
			
		||||
    model: "3 Model B+"
 | 
			
		||||
    pcb_rev: "1.3"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  9020e0:
 | 
			
		||||
    release: "Q4 2018"
 | 
			
		||||
    model: "3 Model A+"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "512 MB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a02100:
 | 
			
		||||
    release: "Q1 2019"
 | 
			
		||||
    model: "Compute Module 3+"
 | 
			
		||||
    pcb_rev: "1.0"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  a03111:
 | 
			
		||||
    release: "Q2 2019"
 | 
			
		||||
    model: "4 Model B"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "1 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  b03111:
 | 
			
		||||
    release: "Q2 2019"
 | 
			
		||||
    model: "4 Model B"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "2 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  c03111:
 | 
			
		||||
    release: "Q2 2019"
 | 
			
		||||
    model: "4 Model B"
 | 
			
		||||
    pcb_rev: "1.1"
 | 
			
		||||
    mem: "4 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  c03112:
 | 
			
		||||
    model: "4 Model B"
 | 
			
		||||
    pcb_rev: "1.2"
 | 
			
		||||
    mem: "4 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
  c03114:
 | 
			
		||||
    model: "4 Model B"
 | 
			
		||||
    pcb_rev: "1.4"
 | 
			
		||||
    mem: "8 GB"
 | 
			
		||||
    notes: "(Mfg by Sony)"
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user