finish partitionning
This commit is contained in:
parent
2b1a9b7214
commit
3ee290940d
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,3 +9,6 @@
|
|||||||
packer/assets/id_rsa_qemu*
|
packer/assets/id_rsa_qemu*
|
||||||
packer/assets/packer_cache/
|
packer/assets/packer_cache/
|
||||||
packer/assets/output_gentoo_qcow2/
|
packer/assets/output_gentoo_qcow2/
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
@ -5,3 +5,7 @@ Run packer into docker container with qemu to build qcow2 gentoo os
|
|||||||
## use
|
## use
|
||||||
|
|
||||||
run `make up` to start container and build qcow2
|
run `make up` to start container and build qcow2
|
||||||
|
|
||||||
|
## iso checksum
|
||||||
|
|
||||||
|
`iso_checksum_url": "http://distfiles.gentoo.org/releases/amd64/autobuilds/current-install-amd64-minimal/install-amd64-minimal-{{user `version`}}.iso.DIGESTS`
|
@ -11,7 +11,7 @@ WORKDIR /packer
|
|||||||
|
|
||||||
RUN apk add --update qemu qemu-system-x86_64 qemu-img \
|
RUN apk add --update qemu qemu-system-x86_64 qemu-img \
|
||||||
vim htop util-linux gzip sysfsutils openssh-client \
|
vim htop util-linux gzip sysfsutils openssh-client \
|
||||||
openssh-keygen sudo ansible sshpass
|
openssh-keygen sudo ansible sshpass curl
|
||||||
|
|
||||||
RUN addgroup -g 1000 "${GROUP}" && \
|
RUN addgroup -g 1000 "${GROUP}" && \
|
||||||
adduser -u 1000 -D -G "${GROUP}" "${USER}" && \
|
adduser -u 1000 -D -G "${GROUP}" "${USER}" && \
|
||||||
|
2
packer/assets/ansible/ansible.cfg
Normal file
2
packer/assets/ansible/ansible.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[defaults]
|
||||||
|
host_key_checking = false
|
@ -1,3 +1,4 @@
|
|||||||
[default]
|
[default]
|
||||||
100.64.0.24 ansible_ssh_pass=toor ansible_ssh_port=5556 ansible_user=root
|
100.64.0.24 ansible_ssh_pass=toor ansible_ssh_port=5556 ansible_user=root
|
||||||
|
#192.168.1.24 ansible_ssh_pass=toor ansible_ssh_port=5556 ansible_user=root
|
||||||
|
|
||||||
|
32
packer/assets/ansible/playbook-test.yml
Normal file
32
packer/assets/ansible/playbook-test.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- hosts: localhost
|
||||||
|
vars:
|
||||||
|
my_loop: >
|
||||||
|
[
|
||||||
|
{% for i in range(1, 2) %}
|
||||||
|
{
|
||||||
|
'name':'prefix-{{ i }}'
|
||||||
|
}
|
||||||
|
{% if not loop.last %},{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
]
|
||||||
|
ips_str: |
|
||||||
|
{% for idx in range(0,2) %}
|
||||||
|
- name: 192.168.100.{{ idx }}
|
||||||
|
test: {{ idx }}
|
||||||
|
{% endfor %}
|
||||||
|
ips: "{{ ips_str | from_yaml }}"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- debug:
|
||||||
|
msg: "{{ my_loop }}"
|
||||||
|
- debug:
|
||||||
|
msg: "{{ item.name }}"
|
||||||
|
loop: "{{ my_loop }}"
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: "{{ ips }}"
|
||||||
|
- debug:
|
||||||
|
msg: "{{ item.name }}"
|
||||||
|
loop: "{{ ips }}"
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
- hosts: default
|
- hosts: default
|
||||||
become: true
|
become: true
|
||||||
become_method: su
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: "check ansible required param"
|
- name: "check ansible required param"
|
||||||
assert:
|
assert:
|
||||||
|
@ -3,17 +3,29 @@
|
|||||||
|
|
||||||
devices_path: /dev/sda
|
devices_path: /dev/sda
|
||||||
devices_system:
|
devices_system:
|
||||||
- name: root
|
- name: bootloader
|
||||||
dev: /dev/sda1
|
dev: /dev/sda1
|
||||||
|
label: gpt
|
||||||
|
flags: [ bios_grub ]
|
||||||
|
part_start: 0%
|
||||||
|
part_end: 2MiB
|
||||||
|
- name: boot
|
||||||
|
dev: /dev/sda2
|
||||||
|
label: gpt
|
||||||
|
flags: [ boot, esp ]
|
||||||
|
part_start: 2MiB
|
||||||
|
part_end: 128MiB
|
||||||
|
fstype: "ext2"
|
||||||
|
- name: root
|
||||||
|
dev: /dev/sda3
|
||||||
|
label: gpt
|
||||||
|
flags: [ lvm ]
|
||||||
|
part_start: 128MiB
|
||||||
|
part_end: 100%
|
||||||
|
fstype: "lvm"
|
||||||
|
|
||||||
|
vg_name: vg_system
|
||||||
lvs:
|
lvs:
|
||||||
- name: "bios"
|
|
||||||
size: "2M"
|
|
||||||
type: "bootloader"
|
|
||||||
descr: "BIOS boot partition"
|
|
||||||
- name: "boot"
|
|
||||||
size: "128M"
|
|
||||||
type: "ext2"
|
|
||||||
descr: "Boot/EFI system partition"
|
|
||||||
- name: "swap"
|
- name: "swap"
|
||||||
size: "1G"
|
size: "1G"
|
||||||
type: "swap"
|
type: "swap"
|
||||||
|
@ -1,36 +1,58 @@
|
|||||||
---
|
---
|
||||||
# partition disk to install gentoo
|
# partition disk to install gentoo
|
||||||
|
|
||||||
- name: "Create a new primary partition for LVM"
|
- name: "Create bios, boot and LVM partition"
|
||||||
parted:
|
parted:
|
||||||
device: "{{ devices_path }}"
|
device: "{{ devices_path }}"
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
label: gpt
|
|
||||||
number: "{{ ansible_loop.index }}"
|
number: "{{ ansible_loop.index }}"
|
||||||
flags: [ lvm ]
|
label: "{{ item.label }}"
|
||||||
|
flags: "{{ item.flags }}"
|
||||||
|
part_start: "{{ item.part_start }}"
|
||||||
|
part_end: "{{ item.part_end }}"
|
||||||
state: present
|
state: present
|
||||||
part_end: "100%"
|
|
||||||
loop: "{{ devices_system }}"
|
loop: "{{ devices_system }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
extended: yes
|
extended: yes
|
||||||
|
tags:
|
||||||
|
- storage
|
||||||
|
|
||||||
|
- name: "Format partition with fstype keyword"
|
||||||
|
filesystem:
|
||||||
|
dev: "{{ item.dev }}"
|
||||||
|
fstype: "{{ item.fstype }}"
|
||||||
|
force: yes
|
||||||
|
resizefs: yes
|
||||||
|
loop: "{{ devices_system }}"
|
||||||
|
when: "item.fstype is defined"
|
||||||
|
tags:
|
||||||
|
- storage
|
||||||
|
|
||||||
- name: "Create vg and add disk to it"
|
- name: "Create vg and add disk to it"
|
||||||
lvg:
|
lvg:
|
||||||
vg: vg_system
|
vg: vg_system
|
||||||
pvs: "{{ devices_system | map(attribute='dev') | join(',') }}"
|
pvs: "{{ item.dev }}"
|
||||||
|
force: yes
|
||||||
|
loop: "{{ devices_system }}"
|
||||||
|
when: "'lvm' in item.flags"
|
||||||
|
tags:
|
||||||
|
- storage
|
||||||
|
|
||||||
- name: "Create list of lvs"
|
- name: "Create list of lvs"
|
||||||
lvol:
|
lvol:
|
||||||
vg: "vg_system"
|
vg: "{{ vg_name }}"
|
||||||
lv: "{{ item.name }}"
|
lv: "{{ item.name }}"
|
||||||
size: "{{ item.size }}"
|
size: "{{ item.size }}"
|
||||||
loop: "{{ lvs }}"
|
loop: "{{ lvs }}"
|
||||||
|
tags:
|
||||||
|
- storage
|
||||||
|
|
||||||
|
- name: "Format lvs partition"
|
||||||
|
filesystem:
|
||||||
|
fstype: "{{ item.type }}"
|
||||||
|
dev: "/dev/{{ vg_name }}/{{ item.name }}"
|
||||||
|
force: yes
|
||||||
|
resizefs: yes
|
||||||
|
loop: "{{ lvs }}"
|
||||||
|
tags:
|
||||||
|
- storage
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# run playbook on aready running qemu vm
|
PLAYBOOK="${1:-playbook.yml}"
|
||||||
ansible-playbook -i inventory_test.ini playbook.yml --extra-vars "ssh_pub=$(cat ../id_rsa_qemu) generated_user=antoine generated_group=antoine"
|
DEBUG="-vvv"
|
||||||
|
|
||||||
|
# run playbook on aready running qemu vm
|
||||||
|
ansible-playbook -i inventory_test.ini "$PLAYBOOK" --extra-vars "ssh_pub=$(cat ../id_rsa_qemu) generated_user=antoine generated_group=antoine"
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
"disk_additional_size": [],
|
"disk_additional_size": [],
|
||||||
|
|
||||||
"iso_urls": [
|
"iso_urls": [
|
||||||
"/packer/install-amd64-minimal-{{user `version`}}.iso",
|
"/packer/install-amd64-minimal-20200205T214502Z.iso",
|
||||||
"http://distfiles.gentoo.org/releases/amd64/autobuilds/{{user `version`}}/install-amd64-minimal-{{user `version`}}.iso"
|
"http://distfiles.gentoo.org/releases/amd64/autobuilds/current-install-amd64-minimal//install-amd64-minimal-{{user `version`}}.iso"
|
||||||
],
|
],
|
||||||
"iso_checksum_url": "http://distfiles.gentoo.org/releases/amd64/autobuilds/{{user `version`}}/install-amd64-minimal-{{user `version`}}.iso.DIGESTS.asc",
|
|
||||||
"iso_checksum_type": "file",
|
"iso_checksum_type": "file",
|
||||||
|
"iso_checksum_url": "/packer/install-amd64-minimal-20200205T214502Z.iso.DIGESTS",
|
||||||
"vm_name": "gentoo_packer.qcow2",
|
"vm_name": "gentoo_packer.qcow2",
|
||||||
"output_directory": "output_gentoo_qcow2",
|
"output_directory": "output_gentoo_qcow2",
|
||||||
|
|
||||||
@ -87,7 +86,7 @@
|
|||||||
"extra_arguments": [ "--extra-vars", "ssh_pub={{user `ssh_pub_key`}} generated_user={{user `generated_user`}} generated_group={{user `generated_group`}}" ],
|
"extra_arguments": [ "--extra-vars", "ssh_pub={{user `ssh_pub_key`}} generated_user={{user `generated_user`}} generated_group={{user `generated_group`}}" ],
|
||||||
"groups": "default",
|
"groups": "default",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"ansible_env_vars": [ "ANSIBLE_HOST_KEY_CHECKING=False" ]
|
"ansible_env_vars": [ "ANSIBLE_CONFIG=/packer/ansible/ansible.cfg" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"variables": {
|
"variables": {
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
9bea61ff620257c3343eb3c588c555800488ace01602b7a0e4f89d09a3f976851a81b6501d79cb3696696675b4724c9da82913e4a036f7874a55bfe2b91ee994 install-amd64-minimal-20200205T214502Z.iso
|
||||||
|
|
@ -1,12 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
latest=$(curl -s http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-install-amd64-minimal.txt \
|
||||||
#packer build --only=qemu --var outfile=boxen/gentoo-minimal-hyperv.box --var headless=true --var hyperv_switchname=Ethernet gentoo-minimal.json
|
| grep "^[^#;]" | awk '{print $1}' | cut -d'/' -f1)
|
||||||
|
|
||||||
SSH_PUB=$(cat ./id_rsa_qemu.pub)
|
SSH_PUB=$(cat ./id_rsa_qemu.pub)
|
||||||
|
|
||||||
export PACKER_LOG=1; packer build --only=qemu \
|
export PACKER_LOG=1; packer build --only=qemu \
|
||||||
-var version="20200205T214502Z" \
|
-var version="$latest" \
|
||||||
-var ssh_username="root" \
|
-var ssh_username="root" \
|
||||||
-var ssh_password="toor" \
|
-var ssh_password="toor" \
|
||||||
-var ssh_pub_key="$SSH_PUB" \
|
-var ssh_pub_key="$SSH_PUB" \
|
||||||
|
Loading…
Reference in New Issue
Block a user