UncleNUC Wiki

Second chance for NUCs

User Tools

Site Tools


lab:nuc_2

This is an old revision of the document!


NUC 2

This is the second NUC in the Stack of NUCs.

References

Hardware:

  • 5i3
  • 8GB RAM
  • 32GB storage
  • Wireless

Software:

  • Ubuntu 22.04 LTS server

Purpose:

  • Ansible controller

Steps:

  1. Modify the CIDATA USB stick file user_data to set up an Ansible controller
    • #cloud-config
      autoinstall:
        version: 1
        ssh:
          install-server: true
          # option "allow-pw" defaults to `true` if authorized_keys is empty, `false` otherwise.
          allow-pw: false
      
        # "[late-commands] are run in the installer environment with the installed system mounted at /target."
        late-commands:
          # randomly generate the hostname & show the IP at boot
          - echo nuc-ansible-$(openssl rand -hex 3) > /target/etc/hostname
          # dump the IP out at login screen
          - echo "Ubuntu 22.04 LTS \nIP - $(hostname -I)\n" > /target/etc/issue
          # storage was a pain in the ass and merged multiple things, I just want a 100% use of the fs. (alt option: https://gist.github.com/anedward01/b68e00bb2dcfa4f1335cd4590cbc8484#file-user-data-L97-L199)
          - curtin in-target --target=/target -- lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
          - curtin in-target --target=/target -- resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
          # shut-down the host to avoid an infinite installer loop
          - shutdown -h now
      
        user-data:
          disable_root: true
          timezone: America/New_York
          package_upgrade: false
          packages:
          - network-manager
          - git
          - python3-pip
          runcmd:
          - nmcli d wifi connect SSID password PASSWORD
          users:
            - name: tux
              primary_group: users
              groups: sudo
              lock_passwd: true
              # don't need PW since using SSH, leaving this in though...
              # password is "changeme" - created with `docker run -it --rm alpine mkpasswd --method=SHA-512`
              # passwd: "$5$IWwNqL9VUSDoc4Jv$DEUGR.cZQcbz/QvdCOmU13fX5ZW0rANg8LqkAtX3nBA"
              shell: /bin/bash
              # use cat ~/.ssh/id_rsa.pub or generate to get your public key
              ssh_authorized_keys:
                - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDTK3YYoKho9SvTejt9430NRwu5ZQpwtAQGBbX8piLvLfsrJzzXxWljTvmC63VMAbCy3ii/Z4yReeCt4h7JiFNf+4ggfUmG+SN+6WvRlfKdaQBXKqojNNxVDg/M73CYF/CYjifJYombA1WIFYoZwMSnd4pzuS7pSiMFKEYTznmImgqa40uZfK6My98KTFpbuebeRvF1u/2Q2ISEYRQmHbm79NAj2WPoI73vNDtkKOPn8NU13xQgC4EMlk/Yu0p36THYlMl30iJePhFgNNBTxXBZL41+nn6W9wgfwo78VDNSa0A2Cambad/lYEerSWevsPATU7bf2an7RsDJhvCx58hI4BMl0KQ3/R0MT2OSGU+GHjBzL/T9UHIxN1FynzmwYpI96MEmEqETjG2DzboO93Oo5EkuX/e6wo/ptQ1g9Qarmk66E0shYpTtwQn2mz0Lhv8PD9C/CbZl9QqcQ43yah1MD9PH/OaCj32FpBqDNJp+NuyYbjBDhG5TgGza4yrgww8= jimangel@Jims-MacBook-Pro.local"
              sudo: ALL=(ALL) NOPASSWD:ALL
            - name: ansible
              gecos: Ansible User
              primary_group: users
              groups: sudo
              sudo: ALL=(ALL) NOPASSWD:ALL
              shell: /bin/bash
              lock_passwd: true
              ssh_authorized_keys:
                - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDTK3YYoKho9SvTejt9430NRwu5ZQpwtAQGBbX8piLvLfsrJzzXxWljTvmC63VMAbCy3ii/Z4yReeCt4h7JiFNf+4ggfUmG+SN+6WvRlfKdaQBXKqojNNxVDg/M73CYF/CYjifJYombA1WIFYoZwMSnd4pzuS7pSiMFKEYTznmImgqa40uZfK6My98KTFpbuebeRvF1u/2Q2ISEYRQmHbm79NAj2WPoI73vNDtkKOPn8NU13xQgC4EMlk/Yu0p36THYlMl30iJePhFgNNBTxXBZL41+nn6W9wgfwo78VDNSa0A2Cambad/lYEerSWevsPATU7bf2an7RsDJhvCx58hI4BMl0KQ3/R0MT2OSGU+GHjBzL/T9UHIxN1FynzmwYpI96MEmEqETjG2DzboO93Oo5EkuX/e6wo/ptQ1g9Qarmk66E0shYpTtwQn2mz0Lhv8PD9C/CbZl9QqcQ43yah1MD9PH/OaCj32FpBqDNJp+NuyYbjBDhG5TgGza4yrgww8= jimangel@Jims-MacBook-Pro.local"
          lxd:
            init:
              storage_backend: dir
          # shutdown after first host initial provisioning
          ansible:
            install_method: pip
            package_name: ansible
            run_user: ansible
            galaxy:
              actions:
                - ["ansible-galaxy", "collection", "install", "community.general"]
            setup_controller:
              repositories:
                - path: /home/ansible/my-repo
                  source: git@github.com:holmanb/ansible-lxd-private.git
            run_ansible:
              - playbook_dir: /home/ansible/my-repo
                playbook_name: start-lxd.yml
                timeout: 120
                forks: 1
                private_key: /home/ansible/.ssh/id_rsa
              - playbook_dir: /home/ansible/my-repo
                playbook_name: configure-lxd.yml
                become_user: ansible
                timeout: 120
                forks: 1
                private_key: /home/ansible/.ssh/id_rsa
                inventory: new_ansible_hosts
          power_state:
            mode: poweroff
lab/nuc_2.1681087024.txt.gz ยท Last modified: 2023/04/10 00:37 by user