# -*- mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*- --- - name: "DEBUG: base gentoo.yml" debug: verbosity: 1 msg: "DEBUG: Including base gentoo.yml" # linuxBack52/etc/os-release:NAME="Ubuntu" # linuxBack52/etc/os-release:PRETTY_NAME="Ubuntu 16.04.6 LTS" # linuxBack52/etc/os-release:VERSION_CODENAME=xenial # linuxBack52/etc/os-release:UBUNTU_CODENAME=xenial # linuxClipos50/etc/os-release:NAME=Gentoo # linuxClipos50/etc/os-release:PRETTY_NAME="Gentoo/Linux" # linuxFun64/etc/os-release:NAME="Gentoo" # linuxFun64/etc/os-release:PRETTY_NAME="Funtoo Linux" # linuxPen19/etc/os-release:NAME=Gentoo # linuxPen19/etc/os-release:PRETTY_NAME="Gentoo/Linux" - name: "OS flavour" shell: | if [ -f /etc/os-release ] ; then grep -qi ubuntu /etc/os-release && echo Ubuntu && exit 0 grep -qi gentoo /etc/os-release && echo Gentoo && exit 0 fi for elt in /etc/pentoo-release \ /etc/gentoo-release ; do for foo in Pentoo Gentoo ; do grep -q ^$foo $elt && echo $foo && exit 0 done done exit 1 register: base_os_flavour when: - not ansible_check_mode - BOX_OS_FLAVOR|default('') == '' - name: "set_fact OS flavour" set_fact: BOX_OS_FLAVOR: "{{base_os_flavour.stdout}}" when: - not ansible_check_mode - BOX_OS_FLAVOR|default('') == '' - name: "set_fact OS flavour default Gentoo" set_fact: BOX_OS_FLAVOR: "Gentoo" when: - ansible_check_mode or BOX_OS_FLAVOR|default('') == '' # have to install sudo - block: - name: "make /etc/portage dirs" file: path: "/etc/portage/{{item}}" state: directory mode: 0755 with_items: #? make.profile - package.accept_keywords - package.license - package.mask - package.unmask - package.use - postsync.d - profile - repo.postsync.d - repos.conf - savedconfig - name: "make /usr/portage dirs" file: path: "/usr/portage/{{item}}" state: directory mode: 0755 with_items: - distfiles - packages - metadata when: - "ansible_distribution == 'Gentoo'" - name: clean /etc/profile shell: | umask 0022 [ -f /etc/profile.dst ] && exit 0 mv /etc/profile /etc/profile.dst grep -v ^alias /etc/profile.dst > /etc/profile args: creates: "/etc/profile.dst" - name: /etc/python-exec/python-exec.conf blockinfile: dest: /etc/python-exec/python-exec.conf create: no marker: "# {mark} ANSIBLE MANAGED BLOCK base base_Gentoo.yml" insertafter: '.*Note:.*' block: | python{{BASE_PYTHON3_MINOR}} # python{{BASE_PYTHON2_MINOR}} - name: /etc/python-exec/python3.conf shell: | umask 0022 [ -f /etc/python-exec/python-exec.conf ] || exit 1 cd /etc/python-exec || exit 2 [ -f python2.conf ]|| grep -v ^python3 python-exec.conf > python2.conf [ -f python3.conf ]|| grep -v ^python2 python-exec.conf > python3.conf for PYVER in 2 3 ; do P="BASE_PYTHON${PYVER}_MINOR" PYTHON_MINOR="$(eval echo \$$P)" grep -q $PYTHON_MINOR python$PYVER.conf || \ echo $PYTHON_MINOR >> python$PYVER.conf cat /usr/local/etc/python-exec/python$PYVER-*.lis | while read file ; do [ -e $file.conf ] && continue ln -s python$PYVER.conf $file.conf done done exit 0 args: chdir: /etc/python-exec - name: "stat /etc/conf.d/hostname" stat: path: "/etc/{{ETC_CONF_D}}/hostname" register: base_hostname_ini_exists - block: - name: /etc/conf.d/hostname blockinfile: dest: /etc/{{ETC_CONF_D}}/hostname create: no marker: "# {mark} ANSIBLE MANAGED BLOCK base base_Gentoo.yml" block: | hostname="{{BOX_HOST_NAME}}" when: not base_hostname_ini_exists.stat.exists and BOX_HOST_NAME|default('') != '' # was in base but it uses portage - name: "patch /usr/local/" shell: | for ver in python{{BASE_PYTHON3_MINOR}} python{{BASE_PYTHON2_MINOR}} ; do [ -d /usr/lib/portage/python${ver}/ ] || continue find /usr/lib/portage/python${ver}/ -type f -perm 775 -o -perm 755 | \ grep -v '\.pyo\|\.pyc\|\.dst' | while read file ; do grep -q "PORTAGE_PYTHON:-/usr/bin/python${ver}" $file && continue [ -e $file.dst ] || cp -pi $file $file.dst sed -e "s@PORTAGE_PYTHON:-/usr/bin/python}@PORTAGE_PYTHON:-/usr/bin/python${ver}}@" -i $file done done exit 0 when: - ansible_distribution == 'Gentoo'