Outils pour utilisateurs

Outils du site


blog

Pb apt-get update

Pb appstreamcli

# apt-get update

Fetched 61.8 MB in 12s (5,054 kB/s)                                  
The AppStream system cache was updated, but some errors were detected, which might lead to missing metadata. Refer to the verbose log for more information.
Reading package lists... Done                    
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh-cache > /d
ev/null; fi'                 
E: Sub-process returned an error code 
Solution
appstreamcli refresh-cache --force

Pb apt-get hang out

# strace -ff apt-get update

...
[pid 29158] select(6, [5], [], NULL, {tv_sec=0, tv_usec=500000}) = 0 (Timeout)
[pid 29158] rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
[pid 29158] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
0% [Working]) = 131, "\r0% [Working]", 13
[pid 29158] select(6, [5], [], NULL, {tv_sec=0, tv_usec=500000}) = 0 (Timeout)
[pid 29158] rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
[pid 29158] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
0% [Working]) = 131, "\r0% [Working]", 13
[pid 29158] select(6, [5], [], NULL, {tv_sec=0, tv_usec=500000}) = 0 (Timeout)
[pid 29158] rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
[pid 29158] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
0% [Working]) = 131, "\r0% [Working]", 13
[pid 29158] select(6, [5], [], NULL, {tv_sec=0, tv_usec=500000}) = 0 (Timeout)
[pid 29158] rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
[pid 29158] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
0% [Working]) = 131, "\r0% [Working]", 13
Solution

Corriger /etc/resolv.conf

#domain acme.local
search acme.local
options rotate timeout:1 retries:1
nameserver 192.168.1.1
nameserver 8.8.8.8
2025/03/24 15:06

Cloud - packer.io

Config

Prereq

~/.aws/config

[default]
region = us-east-2
output = table

~/.aws/credentials

[default]
aws_access_key_id = AKIAR5WS3MDOSPIUHRU7
aws_secret_access_key = 
Exécution

packer/example.json

{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": ""
  },
  "provisioners": [{
        "type": "ansible",
        "playbook_file": "../ansible/play-test.yml"
  }],
  "builders": [{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key`}}",
    "secret_key": "{{user `aws_secret_key`}}",
    "region": "us-east-2",
    "source_ami_filter": {
      "filters": {
        "virtualization-type": "hvm",
        "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
        "root-device-type": "ebs"
      },
      "owners": ["099720109477"],
      "most_recent": true
    },
    "instance_type": "t2.micro",
    "ssh_username": "ubuntu",
    "ami_name": "packer-example {{timestamp}}"
  }]
}

ansible/play-test.yml

---

- name: test1
  hosts: all
  become: true

  vars:
    ansible_python_interpreter: /usr/bin/python3

  tasks:
    - name: plop
      shell: echo plop > /plop
packer validate example.json
packer build example.json

Debug

packer build --debug example.json
Pour pouvoir se connecter en SSH sur l'instance.
    "ssh_keypair_name": "nom_de_la_clef_presente_sur_aws",
    "ssh_private_key_file": "/home/admin/.ssh/id_rsa",
ssh_keypair_name Nom de la pair de clefs présente sur AWS. Utilisé par AWS pour créer l'instance
ssh_private_key_file Chemin de la clef privée pour que Packer puisse se connecter sur l'instance

Normalement seul ssh_username est nécessaire à la création de l'AMI.

Pour se connecter en SSH sur une instance déjà crée
$ ps -ef |grep ssh 
ssh -o ControlMaster=auto -o ControlPersist=30m -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o Port=39087 -o IdentityFile="/tmp/ansible-key896233465" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User="admin" -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/d7af4b579b 127.0.0.1 /bin/sh
ssh admin@localhost -i /tmp/ansible-key896233465 -p 39087 /bin/bash
 
ansible-playbook --extra-vars packer_build_name=amazon-ebs -e packer_builder_type=amazon-ebs -i /tmp/packer-provisioner-ansible966542596 /home/admin/workspace/Deploy_AMI_SCM_v2/905239-packebuild/ansible/playbook.yml -e ansible_ssh_private_key_file=/tmp/ansible-key896233465
2025/03/24 15:06

Pb apt update Debian9 - Err dep-11 404 Not Found

Contexte : Pb lors de la mise à jour depuis une ancienne Debian 9 testing

Le même pb et solution sur Ubuntu : https://askubuntu.com/questions/786733/apt-get-update-command-not-working-from-xenial-local-Mirror

La solution proposée fonctionne :

rm /etc/apt/apt.conf.d/50appstream

Autre solution : Désinstaller appstream

apt-get purge $(dpkg -l |grep appstream |awk '{print $2}') 
2025/03/24 15:06

Pb Apache ProxyPass 502 503 mod_proxy 100-continue

Voir :

curl -m5 -X PUT --write-out "http_code=%{http_code}" --data @submit.xml http://127.0.0.1/CTRL/submit?EBu
curl -m5 -X PUT --write-out "http_code=%{http_code}" --data @submit.xml http://127.0.0.1:8080/I/submit?EBu

Solution

Solution 1

RequestHeader unset Expect early

/etc/httpd/conf/httpd.conf

LoadModule headers_module modules/mod_headers.so
 
<IfModule mod_headers.c>
RequestHeader unset Expect early
</IfModule>
Solution 2
<IfVersion >= 2.4.41>
    Proxy100Continue off
</IfVersion>
2025/03/24 15:06

Pb Ansible Python3 replace regexp err cannot use a string pattern on a bytes-like object

Source : https://github.com/ansible/ansible/pull/18822/commits/d3e372fc378ec69f30c25918892cd536a9c24748

Debian Jessie - Ansible jessie-backports

- name: vim no mouse
  replace:
    dest: /usr/share/vim/vim80/defaults.vim
    regexp: '^\s+set mouse=a'
    replace: '"  set mouse=a'

Erreur

TASK [standard : vim no mouse] ***************************************************                                                           
fatal: [plop]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 192.168.134.163 closed.\r\n", "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_mx2mi0o7/ansible_module_re
place.py\", line 180, in <module>\r\n    main()\r\n  File \"/tmp/ansible_mx2mi0o7/ansible_module_replace.py\", line 153, in main\r\n    result = re.subn(mre, params['replace'], contents, 0)\r\n  File \"/usr/lib/python3.5/re.py\", line 193
, in subn\r\n    return _compile(pattern, flags).subn(repl, string, count)\r\nTypeError: cannot use a string pattern on a bytes-like object\r\n", "msg": "MODULE FAILURE"}
        to retry, use: --limit @/home/jibe/ansible/play-ghost-debian9-std-dev.retry
$ ansible --version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

~/.ansible/hosts

[all:vars]
ansible_python_interpreter=/usr/bin/env python3
 
[plop]
plop
 
[plop:vars]
ansible_python_interpreter=/usr/bin/python3

Solution :

ansible-python3-replace.patch

+++ /usr/lib/python2.7/dist-packages/ansible/modules/core/files/replace.py      2017-10-31 11:49:52.296243787 +0100
@@ -149,8 +149,8 @@
             'before': contents,
         }
 
-    mre = re.compile(params['regexp'], re.MULTILINE)
-    result = re.subn(mre, params['replace'], contents, 0)
+    mre = re.compile(to_bytes(params['regexp']), re.MULTILINE)
+    result = re.subn(mre, to_bytes(params['replace']), contents, 0)
 
     if result[1] > 0 and contents != result[0]:
         msg = '%s replacements made' % result[1]
@@ -175,6 +175,7 @@
 
 # this is magic, see lib/ansible/module_common.py
 from ansible.module_utils.basic import *
+from ansible.module_utils._text import to_bytes
 
 if __name__ == '__main__':
     main()
cd /
patch -p0 < ~/ansible-python3-replace.patch
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