Commit 3b59f22f authored by Reimar Stier's avatar Reimar Stier

Update partitioning; install miniconda

parent 75245c29
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
.vagrant/ .vagrant/
.idea/ .idea/
roles/ roles/
disks
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'yaml' require 'yaml'
DISKS = YAML.load_file('disks.yml')['storage_disks'] DISKS = YAML.load_file('disks/disks.yml')['storage_disks']
BOX_NAME = "devbox" BOX_NAME = "devbox"
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
...@@ -39,12 +39,12 @@ Vagrant.configure("2") do |config| ...@@ -39,12 +39,12 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--accelerate2dvideo", "on"] vb.customize ["modifyvm", :id, "--accelerate2dvideo", "on"]
# Adding a SATA controller that allows 4 hard drives # Adding a SATA controller that allows 4 hard drives
unless File.exist?(DISKS[0]["name"] + ".vmdk") unless File.exist?("disks/" + DISKS[0]["name"] + ".vmdk")
vb.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 4] vb.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 4]
end end
DISKS.each do |disk| DISKS.each do |disk|
datadisk = disk["name"] + ".vmdk" datadisk = "disks/" + disk["name"] + ".vmdk"
unless File.exist?(datadisk) unless File.exist?(datadisk)
vb.customize ['createmedium', '--filename', datadisk,'--format', 'VMDK', '--variant', 'Standard', '--size', disk["size"] * 1024] vb.customize ['createmedium', '--filename', datadisk,'--format', 'VMDK', '--variant', 'Standard', '--size', disk["size"] * 1024]
end end
......
...@@ -3,20 +3,17 @@ storage_disks: ...@@ -3,20 +3,17 @@ storage_disks:
- name: "home" - name: "home"
size: 50 size: 50
port: 1 port: 1
dev: "/dev/sda" device: "/dev/sdb"
mount: "/home" mount: "/home"
- name: opt
size: 15
port: 2
dev: "/dev/sdb"
mount: "/opt"
- name: docker - name: docker
size: 40 size: 40
port: 3 port: 3
dev: "/dev/sdc" device: "/dev/sdc"
mount: "/var/lib/docker" mount: "/var/lib/docker"
- name: root
size: 40 # shadows /opt/VBoxGuestAdditions-6.0.10
port: 3 #- name: opt
dev: "/dev/sdc" # size: 20
mount: "/" # port: 2
# device: "/dev/sdd"
# mount: "/opt"
...@@ -7,7 +7,7 @@ base_locales_default: "de_DE.UTF-8" ...@@ -7,7 +7,7 @@ base_locales_default: "de_DE.UTF-8"
base_timezone: "Europe/Berlin" base_timezone: "Europe/Berlin"
base_custom_packages: base_custom_packages:
system: ['apt-file', 'unzip', 'gparted', 'mailutils', 'tree', 'iotop'] system: ['rsync', 'apt-file', 'unzip', 'gparted', 'mailutils', 'tree', 'iotop']
shell: ['tmux'] shell: ['tmux']
system_dns: ['haveged', 'bind9utils'] system_dns: ['haveged', 'bind9utils']
revision: ['git', 'subversion'] revision: ['git', 'subversion']
......
https://repo.anaconda.com/archive/
...@@ -20,3 +20,5 @@ ...@@ -20,3 +20,5 @@
post_tasks: post_tasks:
- import_tasks: tasks/xfce4_configuration.yml - import_tasks: tasks/xfce4_configuration.yml
tags: desktop_config tags: desktop_config
- import_tasks: tasks/install_conda.yml
tags: conda
- name: Check Conda installation
stat:
path: /opt/miniconda3
get_checksum: false
register: check_conda
- name: Install Conda
block:
- name: Download Miniconda
get_url:
url: https://repo.continuum.io/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh
dest: /tmp/install-miniconda.sh
checksum: md5:718259965f234088d785cad1fbd7de03
mode: 0550
- name: Create conda folder
file:
path: /opt/miniconda3
state: directory
owner: vagrant
mode: 755
recurse: true
- name: Run the installer
shell: /tmp/install-miniconda.sh -b -u -p /opt/miniconda3
- name: Remove the installer
file:
state: absent
path: /tmp/install-miniconda.sh
- name: Add miniconda bin to path
shell: echo 'export PATH=/opt/miniconda3/bin:$PATH' >> /etc/profile
- name: conda - read permission for all
file:
path: /opt/miniconda3
owner:
mode: +r
recurse: true
- name: conda - execution permission for all
file:
path: /opt/miniconda3/bin
mode: +x
recurse: true
when: not check_conda.stat.exists
- name: Mount and bind root volume for copying
mount:
path: /mnt/root/
src: /
opts: bind
state: mounted
fstype: ext4
- name: Mount new home volume for copying
mount:
path: /mnt/home/
src: "{{ storage_home_info[0]['device'] }}1"
state: mounted
fstype: ext4
- name: Check if vagrant home directory exists
stat:
path: /mnt/home/vagrant/
get_checksum: false
register: vagrant_home
- name: Restore vagrant home directory if not present
delegate_to: devbox
synchronize:
src: /mnt/root/home/vagrant/
dest: /mnt/home/vagrant/
when: not vagrant_home.stat.exists
- include_vars: disks.yml - include_vars: disks/disks.yml
- debug: msg="{{ storage_disks }}" - debug: msg="{{ storage_disks }}"
- debug: msg="{{ ansible_mounts }}" - debug: msg="{{ ansible_mounts }}"
- debug: msg="{{ ansible_mounts | selectattr('mount', 'match', '^' + disk['mount'] + '$') | list }}" - debug: msg="{{ ansible_mounts | selectattr('mount', 'match', '^' + disk['mount'] + '$') | list }}"
loop: "{{ storage_disks }}" loop: "{{ storage_disks }}"
loop_control: loop_control:
loop_var: disk loop_var: disk
- name: Install rsync
package:
name: ["rsync", "parted"]
state: present
- name: Set empty list as default for storage discs to create
set_fact:
storage_disks_to_create: []
- name: Create list of discs to be partitioned, formatted, mounted
set_fact:
storage_disks_to_create: "{{ [disk] + (storage_disks_to_create | default([])) }}"
loop: "{{ storage_disks }}"
loop_control:
loop_var: disk
when: "{{ ansible_mounts | selectattr('mount', 'match', '^' + disk['mount'] + '$') | list | length == 0 }}"
- name: Check if home storage is newly created
set_fact:
storage_home_info: "{{ storage_disks_to_create | selectattr('mount', 'match', '^/home$') | list }}"
storage_home_is_new: "{{ storage_disks_to_create | selectattr('mount', 'match', '^/home$') | list | length > 0 }}"
- debug: msg="{{ storage_disks_to_create }}"
- name: Create a new primary partitions
parted:
device: "{{ disk['device'] }}"
number: 1
state: present
loop: "{{ storage_disks_to_create }}"
loop_control:
loop_var: disk
- name: Create filesystems
filesystem:
fstype: ext4
dev: "{{ disk['device'] }}1"
loop: "{{ storage_disks_to_create }}"
loop_control:
loop_var: disk
- import_tasks: move_home.yml
when: storage_home_is_new
- name: Mount filesystems
mount:
fstype: ext4
src: "{{ disk['device'] }}1"
path: "{{ disk['mount'] }}"
state: mounted
loop: "{{ storage_disks_to_create }}"
loop_control:
loop_var: disk
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