-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_generic-icub-machine.yml
167 lines (141 loc) · 4.45 KB
/
setup_generic-icub-machine.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
- name: setup generic icub machine
hosts: localhost
connection: local
debugger: true
vars:
target_ansible_min_version: "2.11"
target_robot: icub
tasks:
- name: Print all available facts
ansible.builtin.debug:
var: ansible_facts
# Preliminary checks
- name: Verify Ansible version is at least {{target_ansible_min_version}}
assert:
that: "ansible_version.full is version_compare('{{target_ansible_min_version}}', '>=')"
msg: >
"You must update Ansible to at least version {{target_ansible_min_version}}"
# 1. install packages
- name: Ansible Update Cache and Upgrade all Packages
become: true
register: updatesys
apt:
name: "*"
state: latest
update_cache: yes
- name: Install basic packages
become: true
apt:
state: present
name:
- nfs-common
- python-tk
- libopencv-dev
- ssh
- cmake-curses-gui
- linux-image-lowlatency
- linux-headers-lowlatency
- iperf
- libportaudio2
- portaudio19-dev
- linux-sound-base
- alsa-base
- alsa-utils
- gdb
- meld
- bmon
- libi2c-dev
- expect
- libgfortran-10-dev
- qml-module-qt-labs-folderlistmodel
- qml-module-qt-labs-settings
- name: Install optional, but useful packages
become: true
apt:
state: present
name:
- vim
- htop
- iperf3
- net-tools
- nmap
- name: remove not needed packages
command: apt purge -y cloud-guest-utils cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf unattended-upgrades
ignore_errors: true
#2 Creating iCub user if not exists
- name: Creating user {{ target_robot }}
become: true
ansible.builtin.user:
name: "{{ target_robot }}"
state: present
shell: /bin/bash
password: "$y$j9T$xAxXfyYaY2VbD4AMfcF6F/$poSHChpX0hK./OsRvqOcyiwf3luyMNCQM/QWAMnfy84"
groups: sudo
create_home: yes
append: true
# 3. setting ntp client
- name: add 10.0.0.1 as ntp server
become: true
ansible.builtin.lineinfile:
backup: yes
path: /etc/systemd/timesyncd.conf
search_string: "NTP="
insertafter: "#NTP="
line: "NTP=10.0.0.1"
- name: add ntp.ubuntu.com as fall back ntp server
become: true
ansible.builtin.lineinfile:
backup: yes
path: /etc/systemd/timesyncd.conf
search_string: '#FalllbackNTP='
line: "FallbackNTP=ntp.ubuntu.com"
- name: restart service systemd-timesyncd service
become: true
ansible.builtin.service:
name: systemd-timesyncd
state: restarted
#4 real time configuration
- name: Modify the real-time priority
copy:
dest: /etc/security/limits.d/{{target_robot}}.conf
content: |
{{target_robot}} soft rtprio 99
{{target_robot}} hard rtprio 99
- name: Modify max netbuffer
copy:
dest: /etc/sysctl.d/20-net-rbuffer.conf
content: |
net.core.rmem_max=8388608
#5 setup network configuration
- name: remove netplan configurations
command: rm -r /etc/netplan/
ignore_errors: true
- name: import network configurations
command: cp -r netplan_icub/ /etc/netplan
- name: create symlink 50-icub-head.yaml
command: ln -sf /etc/netplan/50-icub-head-static.yaml.notload /etc/netplan/50-icub-head.yaml
#6 setup robot enviroment
- name: create robot folder
command: mkdir -p /usr/local/src/robot
- name: set icub ownership to robot folder
command: chown -R {{target_robot}}:{{target_robot}} /usr/local/src/robot
- name: import bashrc_iCub
command: cp .bashrc_iCub /home/{{target_robot}}/.
- name: add {{target_robot}} to groups
command: usermod -a -G video,audio,tty,dialout,i2c {{target_robot}}
- name: add line to bashrc
ansible.builtin.blockinfile:
path: /home/{{target_robot}}/.bashrc
insertbefore: "# If not running interactively, don't do anything"
block: |
if [[ $- == *i* ]] || [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
#Load the iCub custom bashrc
if [ "$HOME" != "" ]; then
ICUBRC_FILE="${HOME}/.bashrc_iCub"
else
ICUBRC_FILE="/home/icub/.bashrc_iCub"
fi
if [ -f "$ICUBRC_FILE" ]; then
source $ICUBRC_FILE
fi
fi