Verified Commit cb34bbac authored by Tharyrok's avatar Tharyrok
Browse files

Add many fonction (build, post process, pre process, ...)

parent 9c69ca2d
# .ansible-lint
skip_list:
- package-latest # Package installs should not use latest
packer_cache
build-qemu
output
\ No newline at end of file
output
.vagrant
\ No newline at end of file
......@@ -16,7 +16,7 @@ clean-archive: ## Clean up the archives
clean: clean-packer clean-archive ## Cleans up all files produced
build: clean-packer ## Build the packer images
packer build $(CURRENT_DIR)/images
packer build -parallel-builds=4 $(CURRENT_DIR)/images
make-archive: clean-archive ## Create archives
sudo $(CURRENT_DIR)/generate_archive.sh
......
[defaults]
display_skipped_hosts = False
display_ok_hosts = False
\ No newline at end of file
ansible_become: yes
ansible_user: neutrinet
ansible_user: root
ansible_become_password: neutrinet
ansible_become_method: sudo
---
- name: 'Provision Image'
hosts: default
hosts: all
tasks:
- name: Upgrade the OS (deb)
apt:
update_cache: true
cache_valid_time: 3600
upgrade: dist
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- debug:
var: ansible_facts
- name: Upgrade the OS (rpm)
yum:
name: '*'
state: latest
update_cache: true
when: ansible_distribution == 'CentOS'
roles:
- role: rootfs
when: ansible_facts['proc_cmdline']['ketupa_mode'] is not defined
- role: yunohost
when:
- ansible_facts['proc_cmdline']['ketupa_mode'] is not defined
- ansible_facts['nodename'] == 'yunohost-4'
- name: Clean the OS (deb)
apt:
autoclean: true
autoremove: true
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- role: live-rescue-pre
when:
- ansible_facts['proc_cmdline']['ketupa_mode'] is not defined
- ansible_facts['nodename'] == 'live-rescue'
- name: Clean the OS (rpm)
yum:
autoremove: true
when: ansible_distribution == 'CentOS'
- role: live-rescue-post
when:
- ansible_facts['proc_cmdline']['ketupa_mode'] is defined
- ansible_facts['proc_cmdline']['ketupa_mode'] == 'install'
\ No newline at end of file
---
- name: Generate fstab
ansible.builtin.command:
cmd: "genfstab -U /target"
register: genfstab_outpout
- name: write fstab
copy:
content: "{{ genfstab_outpout.stdout }}"
dest: "/target/etc/fstab"
- name: Install grub
ansible.builtin.command:
cmd: "arch-chroot /target grub2-install {{ ketupa['disk'] }}"
when: ketupa['image'] == 'centos-8'
- name: Regenerate grub config
ansible.builtin.command:
cmd: "arch-chroot /target grub-mkconfig -o /boot/grub/grub.cfg"
when: ketupa['image'] == 'debian-10'
---
- name: Read device information (always use unit when probing)
community.general.parted:
device: "{{ ketupa['disk'] }}"
unit: MiB
register: disk_info
- name: Remove all partitions from disk
community.general.parted:
device: "{{ ketupa['disk'] }}"
number: '{{ item.num }}'
state: absent
loop: '{{ disk_info.partitions }}'
---
- name: Create a ext2 filesystem boot partition
community.general.filesystem:
fstype: ext2
dev: "{{ ketupa['disk'] }}2"
- name: Create a xfs filesystem root partition
community.general.filesystem:
fstype: xfs
dev: "{{ ketupa['disk'] }}3"
- name: Create a swap filesystem swpa partition
community.general.filesystem:
fstype: swap
dev: "{{ ketupa['disk'] }}4"
\ No newline at end of file
---
- name: Include Site Vars
include_vars: /opt/ansible/test-ketupa.json
- name: Debug JSON Vars
debug:
msg: "{{ ketupa }}"
\ No newline at end of file
---
- include: load-variable.yaml
- include: disk.yaml
- include: partition.yaml
- include: format.yaml
- include: mount.yaml
- include: unarchive.yaml
- include: config.yaml
\ No newline at end of file
---
- name: create dir for root partition mount
file:
path: /target
owner: root
group: root
mode: "u+rw,g+r,o+r"
state: directory
- name: Mount root partition
ansible.posix.mount:
path: /target
src: "{{ ketupa['disk'] }}3"
fstype: xfs
state: mounted
- name: create dir for boot partition mount
file:
path: /target/boot
owner: root
group: root
mode: "u+rw,g+r,o+r"
state: directory
- name: Mount boot partition
ansible.posix.mount:
path: /target/boot
src: "{{ ketupa['disk'] }}2"
fstype: ext2
state: mounted
- name: Mount swap partition
ansible.builtin.command:
cmd: "swapon {{ ketupa['disk'] }}4"
#- name: Mount swap partition
# ansible.posix.mount:
# path: none
# src: "{{ ketupa['disk'] }}4"
# fstype: swap
# opts: sw
# state: mounted
\ No newline at end of file
---
- name: Create biosboot
community.general.parted:
device: "{{ ketupa['disk'] }}"
part_start: 0%
part_end: 1MiB
flags: [ bios_grub ]
number: 1
label: gpt
unit: MiB
state: present
- name: Create boot partition
community.general.parted:
device: "{{ ketupa['disk'] }}"
part_start: 1MiB
part_end: 1GiB
fs_type : ext2
number: 2
label: gpt
unit: MiB
state: present
- name: Create root partition
community.general.parted:
device: "{{ ketupa['disk'] }}"
part_start: 1025MiB
part_end: -512MiB
fs_type : xfs
number: 3
label: gpt
unit: MiB
state: present
- name: Create swap partition
community.general.parted:
device: "{{ ketupa['disk'] }}"
part_start: -512MiB
part_end: 100%
fs_type : linux-swap
number: 4
label: gpt
unit: MiB
state: present
\ No newline at end of file
---
- name: Extract rootfs
ansible.builtin.unarchive:
src: "/opt/{{ ketupa['image'] }}-latest.tar.zst"
dest: /target
\ No newline at end of file
[Service]
ExecStart=
ExecStart=-/usr/sbin/agetty --autologin root --noclear %I $TERM
\ No newline at end of file
[Service]
ExecStart=
ExecStart=-/usr/sbin/agetty --autologin root --noclear -s %I 115200 vt102
\ No newline at end of file
---
- name: create dir for overide systemd
file:
path: "{{ item }}"
owner: root
group: root
mode: "u+rw,g+r,o+r"
state: directory
with_items:
- /etc/systemd/system/getty@tty1.service.d/
- /etc/systemd/system/serial-getty@ttyS0.service.d/
- name: copy file override tty0
copy:
src: "auto-login/tty1-override.conf"
dest: "/etc/systemd/system/getty@tty1.service.d/override.conf"
owner: root
group: root
mode: "u+rw,g+r,o+r"
- name: copy file override ttyS0
copy:
src: "auto-login/ttyS0-autologin.conf"
dest: "/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf"
owner: root
group: root
mode: "u+rw,g+r,o+r"
\ No newline at end of file
---
- include: tools.yaml
- include: auto-login.yaml
#- include: ansible.yaml
---
- name: Install tools
package:
name:
- python3-pip
- python3-dev
- python3-setuptools
- lvm2
- dmraid
- mdadm
- cryptsetup-bin
- btrfs-progs
- xfsprogs
- extlinux
- exfat-utils
- dosfstools
- parted
- bzip2
- zstd
- dracut
- dracut-network
state: latest
- name: Update pip
pip:
name: pip
state: latest
executable: pip3
- name: Install ansible
pip:
name: ansible
state: latest
executable: pip3
\ No newline at end of file
Supports Markdown
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