roles/ansible-gentoo_install/
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user