Commit 323a12b4 authored by Jakob Levisen Kvistgaard's avatar Jakob Levisen Kvistgaard
Browse files

added ansible prime and ros2 setup for rpi on robotto

parent 56c4ed2a
[all:vars]
drobotti_user=ubuntu
drobotti_password=drobotti
ros_distro=foxy
[robots]
192.168.4.4
[vm]
- name: Prime ubuntu distribution
hosts: robots
remote_user: "{{ drobotti_user }}"
gather_facts: yes
tasks:
- include_role:
name: common
tasks_from: deploy_ssh_key
- include_role:
name: common
tasks_from: auth_on_sudo_remove
- include_role:
name: common
tasks_from: change_password
\ No newline at end of file
##### dev cmds.
- debug:
msg: "{{ ansible_facts }}"
# guide robotti rpi
### prime ubuntu distro
ansible-playbook -i inventory/hosts prime_ubuntu.yml -kK
note: password changed to: drobotti
### Setup robotti
ansible-playbook -i inventory/hosts setup_robotti.yml -k
\ No newline at end of file
- name: Permit sudo excution without authentication fix
become: yes
ansible.builtin.lineinfile:
create: yes
state: present
owner: root
group: root
line: "{{ ansible_user }} ALL=(ALL:ALL) NOPASSWD: ALL"
path: "/etc/sudoers.d/{{ ansible_user }}"
mode: '0400'
\ No newline at end of file
---
- name: Change user password
become: yes
ansible.builtin.user:
name: "ubuntu"
update_password: always
password: "{{ drobotti_password | password_hash('sha512') }}"
\ No newline at end of file
- name: "Deploy {{ item }}"
become: true
ansible.builtin.apt:
update_cache: yes
state: present
pkg: "{{ item }}"
\ No newline at end of file
- name: Register controller user
ansible.builtin.shell:
cmd: whoami
register: whoami_controller
delegate_to: localhost
- name: Register default ssh key (id_rsa)
ansible.builtin.stat:
path: "/home/{{ whoami_controller.stdout }}/.ssh/id_rsa"
register: ssh_key_stat_controller
delegate_to: localhost
- name: Generate ssh-key
community.crypto.openssh_keypair:
path: "/home/{{ whoami_controller.stdout }}/.ssh/id_rsa"
delegate_to: localhost
when: ssh_key_stat_controller.stat.exists == false
- name: Set public key variable
set_fact:
user_public_key: "{{ lookup('file','/home/{{ whoami_controller.stdout }}/.ssh/id_rsa.pub') }}"
- name: Deploy public key
ansible.builtin.lineinfile:
create: yes
state: present
line: "{{ user_public_key }}"
path: "{{ ansible_facts.user_dir }}/.ssh/authorized_keys"
mode: '0600'
\ No newline at end of file
- name: Gather package facts
ansible.builtin.package_facts:
manager: auto
\ No newline at end of file
- name: Install ROS2 dependencies
become: yes
ansible.builtin.apt:
state: present
pkg:
- curl
- gnupg2
- lsb-release
- name: Set ros gpg key
become: yes
ansible.builtin.apt_key:
url: https://raw.githubusercontent.com/ros/rosdistro/master/ros.key
state: present
keyring: /usr/share/keyrings/ros-archive-keyring.gpg
- name: Get dpkg architecture
ansible.builtin.shell:
cmd: dpkg --print-architecture
register: dpkg_architecture
- name: Add ros repository
become: yes
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_architecture.stdout }} signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu {{ ansible_facts.lsb.codename }} main"
state: present
- include_role:
name: common
tasks_from: get_package_facts
- name: Deploy ROS2 Desktop
become: yes
ansible.builtin.apt:
name: "ros-{{ ros_distro }}-desktop"
state: present
when: "'ubuntu-desktop' in ansible_facts.packages"
- name: Deploy ROS2 Base
become: yes
ansible.builtin.apt:
name: "ros-{{ ros_distro }}-ros-base"
state: present
when: "'ubuntu-desktop' not in ansible_facts.packages"
- name: Install python
include_role:
name: common
tasks_from: deploy_apt
with_items:
- python3
- python3-pip
when: "'python3' not in ansible_facts.packages or 'python3-pip' not in ansible_facts.packages"
- name: Deploy colcon build tools
include_role:
name: common
tasks_from: deploy_apt
with_items:
- python3-colcon-common-extensions
- name: Install locales pkg
become: yes
ansible.builtin.apt:
name: locales
state: present
- name: Set locale
become: yes
ansible.builtin.shell:
cmd: locale-gen en_US en_US.UTF-8
- name: Update locale
become: yes
ansible.builtin.shell:
cmd: update-locale LC_ALL=en_US.UTF8 LANG=en_US.UTF8
- name: Export locale
ansible.builtin.shell:
cmd: export LANG=en_US.UTF-8
\ No newline at end of file
- name: Setup Rpi on DesktopRobotti
hosts: robots
remote_user: "{{ drobotti_user }}"
gather_facts: yes
tasks:
- name: ROS2 setup locale
include_role:
name: ros2
tasks_from: locales
- name: Set ROS2 apt sources
include_role:
name: ros2
tasks_from: apt_sources
- name: Install ROS2 and build tools
include_role:
name: ros2
tasks_from: install_ros2
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment