Outils pour utilisateurs

Outils du site


blog

Cloud LVM autoresize partition PV

#! /bin/bash
 
PV_PART=$(pvdisplay -c | cut -d: -f1 | awk '{print $1}' | head -1)
PV_DISK="${PV_PART/[0-9]/}"
parted -s "$PV_DISK" print fix > /dev/null
PARTNB_EXTENDED=$(parted -s "$PV_DISK" print | awk '/extended$/ {print $1}')
PARTNB_LVM=$(parted -s "$PV_DISK" print | awk '/lvm$/ {print $1}')
 
if [ ! -z ${PARTNB_EXTENDED+x} ]; then parted "$PV_DISK" resizepart "$PARTNB_EXTENDED" 100% ; fi
parted -s "$PV_DISK" resizepart "$PARTNB_LVM" 100%
pvresize "$PV_PART"

A corriger :

  • Si plusieurs PV. Car head -1 n'est pas une solution

Fonctionnalité à ajouter

  • UEFI ?
  • Lancement via cloudinit
2025/03/24 15:06

Pb routage asymétrique pare-feux et routage unicast

Description du Pb

Suite à l'ajout d'une nouvelle interface réseaux en DHCP : plus de réseau depuis mon poste 172.20.18.23/24. \ Enfin, perte de connexion de l'interface existante. La nouvelle répond depuis mon poste qui est dans le même VLAN.

Je cherche a garder la 1ere connexion fonctionnelle (depuis mon poste).

J'avais l'IP suivante :

  • 10.115.108.2/26 (default gw 10.115.108.60)

Maintenant j'ai :

  • 10.115.108.2/26 (default gw 10.115.108.60)
  • 172.20.18.19/24

Il y a pourtant bien DEFROUTE=no pour garder la passerelle par défaut de la 1ere interface.

Voyons cela de plus prés.

Nouvelle interface en DHCP

/etc/sysconfig/network-scripts/ifcfg-em3

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=no
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=em3
UUID=da256961-5be0-44c7-8e60-1334d0cfc736
DEVICE=em3
ONBOOT=yes
DEFROUTE=no

Interface existante

/etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
NAME=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.115.108.2
NETMASK=255.255.255.192
GATEWAY=10.115.108.60
BONDING_OPTS="mode=active-backup primary em1 primary_reselect=always miimon=100"
NM_CONTROLLED=no
ip r
 
#cat /etc/iproute2/rt_tables
#ip route show table local
#ip r show table all | egrep -v "^unreachable|^local|^broadcast"
default via 10.115.108.60 dev bond0
10.115.108.0/26 dev bond0  proto kernel  scope link  src 10.115.108.2
169.254.0.0/16 dev em3  scope link  metric 1004
169.254.0.0/16 dev bond0  scope link  metric 1008
172.20.18.0/24 dev em3  proto kernel  scope link  src 172.20.18.19
Eurêka !

En ajoutant la nouvelle interface (DHCP en 172.20.18.19/24) au serveur, il ne sort dorénavant plus par la passerelle par défaut (bond0 10.115.108.60/26) pour mon poste (172.20.18.23/24) mais par cette nouvelle interface. \

Solution

Routage

Précaution au cas où

systemctl start atd
echo "systemctl restart network" | at now +2 min

La solution est d'ajouter une règle de routage que pour moi ! (unicast)

ip r add 172.20.18.23/32 via 10.115.108.60 dev bond0
ip r
default via 10.115.108.60 dev bond0
10.115.108.0/26 dev bond0  proto kernel  scope link  src 10.115.108.2
169.254.0.0/16 dev em3  scope link  metric 1004
169.254.0.0/16 dev bond0  scope link  metric 1008
172.20.18.0/24 dev em3  proto kernel  scope link  src 172.20.18.19
172.20.18.23 via 10.115.108.60 dev bond0

Pour rendre la règle permanente

/etc/sysconfig/network-scripts/route-em3

172.20.18.23/32 via 10.115.108.60 dev bond0
Config sysctl

Voir Why does Red Hat Enterprise Linux 6 and above invalidate / discard packets when the route for outbound traffic differs from the route of incoming traffic?

Autre solution dans le cas où le ping arrive sur une interface et doit repartir pour une autre.

echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter

Ne pas oublier de modifier le fichier /etc/sysctl.conf pour rendre la modif permanente.

2025/03/24 15:06

Pb réseau - ifup command not found

Contournement

sudo dnf install NetworkManager-initscripts-updown

Fichiers :

  • /usr/libexec/nm-ifdown
  • /usr/libexec/nm-ifup
  • /usr/sbin/ifdown
  • /usr/sbin/ifup

Alternative :

# nmcli connection reload
# nmcli networking off
# nmcli networking on
 
ip addr flush dev eth0
nmcli con down eth0
nmcli con up eth0

ou

ip addr flush dev eth0
systemctl restart NetworkManager.service
2025/03/24 15:06

Pb Python - urllib3 - Err OSError setuptools pkg resources pip wheel failed with error code 2

user@srv1:~/openstackcli$ virtualenv .
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/user1/openstackcli/bin/python2
Not overwriting existing python script /home/user1/openstackcli/bin/python (you must use /home/user1/openstackcli/bin/python2)
Installing setuptools, pkg_resources, pip, wheel...
  Complete output from command /home/user1/openstackcli/bin/python2 - setuptools pkg_resources pip wheel:
  Collecting setuptools
Exception:
Traceback (most recent call last):
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/index.py", line 792, in get_page
    "Cache-Control": "max-age=600",
  File "/home/user1/openstackcli/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/home/user1/openstackcli/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/user1/openstackcli/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/user1/openstackcli/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "/home/user1/openstackcli/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/user1/openstackcli/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/user1/openstackcli/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in increment
    total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
----------------------------------------
...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 2375, in <module>
    main()
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main
    symlink=options.symlink)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 992, in create_environment
    download=download,
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 922, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 817, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/user1/openstackcli/bin/python2 - setuptools pkg_resources pip wheel failed with error code 2

Solution

Vérif le réseau et le proxy

export http_proxy=http://192.168.22.20:3128
export https_proxy=http://192.168.22.20:3128
2025/03/24 15:06

Pb Podman container still Stopping

After executing podman system migrate, the container status remained stopping.

Voir Pb podman - podman system migrate

$ podman ps -a
CONTAINER ID  IMAGE                                                                         COMMAND               CREATED       STATUS      PORTS       NAMES
c5c069775351  aap.acme.local/ExecEnv1:0.9.6  ssh-agent sh -c t...  20 hours ago  Stopping                ansib
le_runner_241060
b242fe99cb8f  aap.acme.local/ee-supported-rhel8:latest        ansible-playbook ...  11 hours ago  Stopping                ansib
le_runner_241722

$ podman stop c5c069775351
ERRO[0000] Unable to clean up network for container c5c0697753515cb6ed3a2fdf76d9bcd5248160199dc9d26bfb7953f1de5e9e07: "unmounting network namespace for container c5c0697753515cb6ed3a2fdf76d9bcd5248160199dc9d26bfb7953f1de5e9e07: failed to unmount NS: at /tmp/podman-run-1000/netns/netns-ef973d33-1d85-2e00-b4fa-dc2ef6b6f811: invalid argument"
c5c069775351

$ podman stop c5c069775351
c5c069775351

$ podman stop c5c069775351
c5c069775351

$ podman rm c5c069775351
Error: cannot remove container c5c069775351fca6e99d9b43354e615671cdf0d150def3259e9bc97399db3e96 as it is stopping - running or paused containers cannot be removed without force: container state improper

$ podman rm -f c5c069775351
ERRO[0000] Free container lock: no such file or directory
c5c069775351

ou encore

#podman container kill -a
podman container rm -fa
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki