roles/ansible-gentoo_install/
This commit is contained in:
parent
94c76b2e4b
commit
f2575772ec
11 changed files with 363 additions and 61 deletions
|
@ -103,12 +103,12 @@
|
|||
shell: |
|
||||
cd {{AGI_GENTOO_FROM_MP}} || exit 1
|
||||
for dir in {{AGI_bootstrap_dirs}}; do
|
||||
[ -d "{{AGI_NBD_MP}}/{{dir}}" ] && continue
|
||||
mkdir -p "{{AGI_NBD_MP}}/{{dir}}"
|
||||
[ -d "{{AGI_NBD_MP}}/$dir" ] && continue
|
||||
mkdir -p "{{AGI_NBD_MP}}/$dir"
|
||||
done
|
||||
for file in {{AGI_bootstrap_files}}; do
|
||||
[ -f "{{AGI_NBD_MP}}/{{file}}" ] && continue
|
||||
cp -np "$file" "{{AGI_NBD_MP}}/{{file}}"
|
||||
[ -f "{{AGI_NBD_MP}}/$file" ] && continue
|
||||
cp -np "$file" "{{AGI_NBD_MP}}/$file"
|
||||
done
|
||||
|
||||
# dracut
|
||||
|
|
|
@ -9,13 +9,6 @@
|
|||
- set_fact:
|
||||
AGI_target: Gentoo2
|
||||
|
||||
- name: "ansible-gentoo_install"
|
||||
set_fact:
|
||||
ansible_check_mode: false
|
||||
when:
|
||||
- "'ansible-gentoo_install' in ROLES"
|
||||
- ansible_check_mode is true
|
||||
|
||||
- name: look for nbd partitions
|
||||
shell: |
|
||||
grep nbd /proc/partitions | head -1|sed -e 's/.* //'
|
||||
|
@ -40,7 +33,7 @@
|
|||
[ -d '{{PLAY_ANSIBLE_SRC}}/src/ansible_gentooimgr/gentooimgr' ] || exit 3
|
||||
[ -f '{{PLAY_ANSIBLE_SRC}}/src/ansible_gentooimgr/gentooimgr/__init__.py' ] || exit 4
|
||||
{{ansible_python_interpreter}} \
|
||||
-c "import os sys; sys.path.append('{{PLAY_ANSIBLE_SRC}}/src/ansible_gentooimgr'); import gentooimgr; print(os.path.dirname(gentooimgr.__file__))"
|
||||
-c "import os, sys; sys.path.append('{{PLAY_ANSIBLE_SRC}}/src/ansible_gentooimgr'); import gentooimgr; print(os.path.dirname(gentooimgr.__file__))" || exit 5
|
||||
register: gentooimgr_out
|
||||
check_mode: false
|
||||
ignore_errors: true
|
||||
|
@ -49,18 +42,72 @@
|
|||
|
||||
- name: set AGI_gentooimgr_configs
|
||||
set_fact:
|
||||
AGI_gentooimgr_configs: "{{gentooimgr_out.stdout}}/configs"
|
||||
AGI_gentooimgr_configs: "{{gentooimgr_out.stdout_lines[-1]}}/configs"
|
||||
|
||||
- name: ansible_gentooimgr nbd status
|
||||
- name: check for a gentooimgr base config
|
||||
shell: |
|
||||
if [ -z "{{BOX_NBD_DEV}}" ] ; then
|
||||
echo ERROR: empty "BOX_NBD_DEV" - define it in hosts.yml
|
||||
exit 1
|
||||
fi
|
||||
if ! grep -q "{{BOX_NBD_DEV}}" /proc/partitions ; then
|
||||
echo ERROR: not mounted BOX_NBD_DEV="{{BOX_NBD_DEV}}" - use qemu-nbd
|
||||
exit 2
|
||||
fi
|
||||
exit 0
|
||||
|
||||
- name: make a gentooimgr base config
|
||||
shell: |
|
||||
base=base.json
|
||||
tofile="{{AGI_GENTOOIMGR_CONFIGFILE}}"
|
||||
todir=`dirname "$tofile"`
|
||||
[ -d $todir ] || mkdir $todir
|
||||
if [ ! -f "$tofile" ] ; then
|
||||
if [ -f "{{AGI_gentooimgr_configs}}/$base" ] ; then
|
||||
cp -p "{{AGI_gentooimgr_configs}}/$base" "$tofile" || exit 2
|
||||
else
|
||||
echo WARN: FNF "{{AGI_gentooimgr_configs}}/$base"
|
||||
# use base.json
|
||||
fi
|
||||
fi
|
||||
# should operate on json with jq
|
||||
# "imgsize": "20G",
|
||||
# "memory": 4096,
|
||||
# "mountpoint": "/mnt/gentoo",
|
||||
# "imagename": null,
|
||||
# "initsys": "openrc",
|
||||
# "iso": null,
|
||||
# "portage": null,
|
||||
# "stage3": null,
|
||||
# "partition": 1
|
||||
if [ -f "$tofile" ] ; then
|
||||
# but this is crucial
|
||||
# "disk": "/dev/sda",
|
||||
sed -i -e 's@"disk": ".*"@"disk": "'{{BOX_NBD_DEV}}'"@' $tofile
|
||||
grep {{BOX_NBD_DEV}} $tofile || exit 4
|
||||
fi
|
||||
|
||||
- name: check for library/ansible_gentooimgr.py
|
||||
shell: |
|
||||
# find it
|
||||
[ -f '{{PLAY_ANSIBLE_SRC}}/library/ansible_gentooimgr.py' ] || exit 1
|
||||
# run it
|
||||
echo '{}' | \
|
||||
{{ansible_python_interpreter}} \
|
||||
'{{PLAY_ANSIBLE_SRC}}/library/ansible_gentooimgr.py' 2>&1| \
|
||||
grep "Unable to figure out what parameters were passed" && exit 0
|
||||
echo WARN: ansible_gentooimgr.py BROKEN
|
||||
|
||||
- name: ansible_gentooimgr NBD STATUS
|
||||
ansible_gentooimgr:
|
||||
action: status
|
||||
loglevel: "{{BOX_NBD_LOGLEVEL}}"
|
||||
threads: 1
|
||||
config: base.config
|
||||
config: "{{AGI_GENTOOIMGR_CONFIGFILE}}" # base.json - bare filename in configs
|
||||
profile: "{{BOX_NBD_BASE_PROFILE}}"
|
||||
kernel_dir: "{{BOX_NBD_KERNEL_DIR}}"
|
||||
portage: '{{BOX_NBD_PORTAGE_FILE}}'
|
||||
stage3: '{{BOX_NBD_STAGE3_FILE }}'
|
||||
portage: "{{BOX_NBD_PORTAGE_FILE}}"
|
||||
stage3: "{{BOX_NBD_STAGE3_FILE }}"
|
||||
temporary_dir: "{{BOX_NBD_BASE_DIR}}"
|
||||
download_dir: "{{AGI_NBD_FILES}}"
|
||||
register: ansible_gentooimgr_out
|
||||
|
|
|
@ -12,20 +12,6 @@
|
|||
[ -d "{{AGI_NBD_MP}}" ] || exit 3
|
||||
check_mode: false
|
||||
|
||||
- name: gpg keys system
|
||||
# Option --keyserver must be used to
|
||||
environment: "{{proxy_env}}"
|
||||
shell: |
|
||||
/usr/bin/gpg --list-keys | grep "{{ item.uid }}" || \
|
||||
/usr/bin/gpg --recv-keys \
|
||||
--keyserver "{{ AGI_GPG_SERVER }}" "{{ item.uid }}"
|
||||
with_items: "{{ agi_gpg_keys_system }}"
|
||||
when:
|
||||
- agi_gpg_keys_system|length > 0
|
||||
- BASE_ARE_CONNECTED|default('') != ''
|
||||
# FixMe:
|
||||
ignore_errors: true
|
||||
|
||||
- name: check files dir
|
||||
environment: "{{shell_env}}"
|
||||
shell: |
|
||||
|
@ -138,6 +124,20 @@
|
|||
when:
|
||||
- "ansible_distribution == 'Gentoo'"
|
||||
|
||||
- name: gpg keys system
|
||||
# Option --keyserver must be used to
|
||||
environment: "{{proxy_env}}"
|
||||
shell: |
|
||||
/usr/bin/gpg --list-keys | grep "{{ item.uid }}" || \
|
||||
/usr/bin/gpg --recv-keys \
|
||||
--keyserver "{{ AGI_GPG_SERVER }}" "{{ item.uid }}"
|
||||
with_items: "{{ agi_gpg_keys_system }}"
|
||||
when:
|
||||
- agi_gpg_keys_system|length > 0
|
||||
- BASE_ARE_CONNECTED|default('') != ''
|
||||
# FixMe:
|
||||
ignore_errors: true
|
||||
|
||||
- name: test portage tarball gpg our copy
|
||||
environment: "{{shell_env}}"
|
||||
shell: |
|
||||
|
@ -145,6 +145,8 @@
|
|||
gpg --list-keys | grep E1D6ABB63BFCFB4BA02FDF1CEC590EEAC9189250 || exit 2
|
||||
gpg --verify "{{AGI_NBD_FILES}}/{{ latest_portage_tarball }}.gpgsig" \
|
||||
"{{AGI_NBD_FILES}}/{{ latest_portage_tarball }}" || exit 3$?
|
||||
# FixMe:
|
||||
ignore_errors: true
|
||||
|
||||
- name: extract portage tarball
|
||||
unarchive:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue