Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Koaxiel committed Feb 7, 2021
1 parent c87e3cb commit 7b10402
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
archlinux*.iso
archlive
2 changes: 1 addition & 1 deletion inventory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[localhost]
localhost ansible_python_interpreter=/usr/bin/python2 ansible_connection=local
localhost ansible_connection=local
6 changes: 1 addition & 5 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
connection: local

roles:
- { role: archiso, tags: archiso, become: yes }
- { role: libvirt, tags: libvirt }
- { role: archiso, tags: archiso, become: yes }
- { role: vagrant, tags: vagrant }

# install libvirt ebtables, etc, nfs
#plugin install vagrant libvirt
#nvram = "/usr/share/ovmf/x64/ovmf_code_x64.bin:/usr/share/ovmf/x64/ovmf_vars_x64.bin"
74 changes: 26 additions & 48 deletions roles/archiso/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,79 +20,57 @@
dest: "{{ archiso_dir }}/archlive"
become: yes

- name: Change airootfs size
lineinfile:
backrefs: yes
path: "{{ item }}"
regexp: '^(options(?!.*\bcow_spacesize=1G\b).*)$'
line: '\1 cow_spacesize=1G'
become: yes
with_items:
- "{{ archiso_dir }}/archlive/efiboot/loader/entries/archiso-x86_64-cd.conf"
- "{{ archiso_dir }}/archlive/efiboot/loader/entries/archiso-x86_64-usb.conf"

- name: Add ansible & git package
lineinfile:
dest: "{{ archiso_dir }}/archlive/packages.x86_64"
path: "{{ archiso_dir }}/archlive/packages.x86_64"
insertbefore: BOF
state: present
line: "{{ item }}"
become: yes
with_items:
loop:
- ansible
- git

- name: Git clone koaxiel
git:
depth: 1
repo: "https://github.com/Koaxiel/koaxiel.git"
dest: "{{ archiso_dir }}/archlive/airootfs/root/koaxiel/"

- name: Override [email protected]
copy:
content: |
[Service]
ExecStop=
ExecStop=/usr/bin/dhcpcd -k %I
dest: "{{ archiso_dir }}/archlive/airootfs/etc/systemd/system/[email protected]/override.conf"
become: yes

- name: Change mirrorlist
lineinfile:
dest: "{{ archiso_dir }}/archlive/airootfs/root/customize_airootfs.sh"
line: "curl -o /etc/pacman.d/mirrorlist 'https://www.archlinux.org/mirrorlist/?country=FR&protocol=http&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on'"
insertbefore: 'sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist'
become: yes

- name: Enable sshd
lineinfile:
dest: "{{ archiso_dir }}/archlive/airootfs/root/customize_airootfs.sh"
line: "systemctl enable sshd.service"
become: yes

- name: Set root password
- name: Permit ssh with empty password
lineinfile:
dest: "{{ archiso_dir }}/archlive/airootfs/root/customize_airootfs.sh"
line: "echo 'root:toto' | chpasswd"
path: "{{ archiso_dir }}/archlive/airootfs/etc/ssh/sshd_config"
insertafter: '#PermitEmptyPasswords no'
line: PermitEmptyPasswords yes
become: yes

- name: Set locale.conf
- name: Install locale config
copy:
src: files/locale.conf
dest: "{{ archiso_dir }}/archlive/airootfs/etc/locale.conf"
src: 'files/{{ item }}'
dest: '{{ archiso_dir }}/archlive/airootfs/etc/{{ item }}'
become: yes
loop:
- locale.conf
- vconsole.conf

- name: Set vconsole
copy:
src: files/vconsole.conf
dest: "{{ archiso_dir }}/archlive/airootfs/etc/vconsole.conf"
become: yes
- name: Add mirrolist
get_url:
url: 'https://www.archlinux.org/mirrorlist/?country=FR&protocol=http&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on'
dest: '{{ archiso_dir }}/archlive/airootfs/etc/pacman.d/mirrorlist'

- name: Add wpa_supplicant-wired.conf in root
- name: Add wpa_supplicant-wired.conf in root folder
copy:
src: files/wpa_supplicant-wired.conf
dest: "{{ archiso_dir }}/archlive/airootfs/root/wpa_supplicant-wired.conf"
become: yes

- name: Build iso
command: "bash {{ archiso_dir }}/archlive/build.sh -v -w {{ archiso_dir }}/archlive/work -o {{ archiso_dir }}"
command: "mkarchiso -v -w {{ archiso_dir }}/archlive/work -o {{ archiso_dir }} {{ archiso_dir }}/archlive"
become: yes

- name: Copy image to libvirt storage
copy:
src: '{{ item }}'
dest: '/var/lib/libvirt/images/archlinux.iso'
with_fileglob: '*.iso'
become: yes
34 changes: 21 additions & 13 deletions roles/libvirt/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
# tasks file for libvirt
- name: Install packages
pacman:
name: [virt-manager, ovmf]
name: [virt-manager, edk2-ovmf, dnsmasq]
state: present
update_cache: yes
become: yes
#- name: Install virt-manager
#
#
#- name: Add nvram qemu.conf
#- name: Change user for qemu.conf
#
#- name: Add user in libvirt group
#
#
#
#
#- name: Startd libvirt

- name: Add user to group libvirt
user:
name: '{{ ansible_user_id }}'
groups: libvirt
append: yes
become: yes

- name: Start libvirt service
systemd:
name: libvirtd
enabled: yes
state: started
become: yes

- name: Start virtlogd service
systemd:
name: virtlogd
state: started
become: yes
15 changes: 2 additions & 13 deletions roles/vagrant/files/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Vagrant.configure("2") do |config|

config.ssh.username = 'root'
config.ssh.password = 'toto'

# Mount NFS folder
config.vm.synced_folder '.', '/vagrant', type: "nfs",
Expand All @@ -28,7 +27,6 @@ Vagrant.configure("2") do |config|
# Reload the VM
config.vm.provision :reload


# Run laptop_setup
config.vm.provision "laptop", type: "ansible_local" do |ansible|
ansible.inventory_path = "/vagrant/koaxiel/laptop_setup/inventory"
Expand All @@ -44,14 +42,8 @@ Vagrant.configure("2") do |config|

config.vm.define :archlinux do |archlinux|
# Box name
#
archlinux.vm.box = "archlinux"

# Domain Specific Options
#
# See README for more info.
#

# Options for libvirt vagrant provider.
archlinux.vm.provider :libvirt do |libvirt|

Expand All @@ -78,16 +70,13 @@ Vagrant.configure("2") do |config|
# be stored.
libvirt.storage_pool_name = "default"

# Set a prefix for the machines that's different than the project dir name.
#libvirt.default_prefix = ''

libvirt.memory = 2024
libvirt.cpus = 2
libvirt.cpu_mode = 'host-passthrough'

libvirt.disk_bus = 'sata'
libvirt.storage :file, :device => :cdrom, :path => '/var/lib/libvirt/images/archlinux-2019.03.10-x86_64.iso'
libvirt.loader = '/usr/share/ovmf/x64/OVMF_CODE.fd'
libvirt.storage :file, :device => :cdrom, :path => '/var/lib/libvirt/images/archlinux.iso'
libvirt.loader = '/usr/share/edk2-ovmf/x64/OVMF_CODE.fd'
libvirt.boot 'hd'
libvirt.boot 'cdrom'

Expand Down
24 changes: 9 additions & 15 deletions roles/vagrant/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
update_cache: yes
become: yes

# - name: Create folder
- name: Install vagran-libvirt and vagrant-reload plugin
command: VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT=1 vagrant plugin install vagrant-libvirt vagrant-reload
args:
creates: '{{ ansible_user_dir }}/.vagrant.d/plugins.json'

- name: Add archlinux box
command: vagrant box add files/package.box --name archlinux
args:
creates: '{{ ansible_user_dir }}/.vagrant.d/boxes/archlinux/0/libvirt/box.img'

# - name: Create folder
# - name: Create VagrantFile



# - name: Install Vagrant plugins

# vagrant plugin install

# vagrant-libvirt
# vagrant-reload


# - name: Setup nfs

# - name: Add Vagrant box

0 comments on commit 7b10402

Please sign in to comment.