admin 管理员组

文章数量: 1086019

Getting error when creating the ubuntu 2404 image .

FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):
File "/tmp/ansible-tmp-1743068631.520732-94183-75803486625763/AnsiballZ_apt_repository.py", line 107, in
_ansiballz_main()
File "/tmp/ansible-tmp-1743068631.520732-94183-75803486625763/AnsiballZ_apt_repository.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/tmp/ansible-tmp-1743068631.520732-94183-75803486625763/AnsiballZ_apt_repository.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible.modules.apt_repository', init_globals=dict(_module_fqn='ansible.modules.apt_repository', _modlib_path=modlib_path),
File "", line 226, in run_module
File "", line 98, in _run_module_code
File "", line 88, in _run_code
File "/tmp/ansible_apt_repository_payload_lau7f97l/ansible_apt_repository_payload.zip/ansible/modules/apt_repository.py", line 679, in
File "/tmp/ansible_apt_repository_payload_lau7f97l/ansible_apt_repository_payload.zip/ansible/modules/apt_repository.py", line 656, in main
File "/usr/lib/python3/dist-packages/apt/cache.py", line 157, in init
self.open(progress)
File "/usr/lib/python3/dist-packages/apt/cache.py", line 214, in open
self._cache = apt_pkg.Cache(progress)
^^^^^^^^^^^^^^^^^^^^^^^
apt_pkg.Error: E:Conflicting values set for option Signed-By regarding source / cloud-sdk: /usr/share/keyrings/google-cloud-archive-keyring.gpg != , E:The list of sources could not be read.
Shared connection to 127.0.0.1 closed.", "module_stdout": "", "msg": "MODULE FAILURE
See stdout/stderr for the exact error", "rc": 1}

Using the below ansible tasks

    - name: Download the new Google Cloud GPG key
  shell: |
    curl -fsSL .gpg | gpg --dearmor -o /usr/share/keyrings/google-cloud-archive-keyring.gpg
  args:
    creates: /usr/share/keyrings/google-cloud-archive-keyring.gpg

- name: Add Google Cloud repository to APT sources
  copy:
    dest: /etc/apt/sources.list.d/google-cloud.list
    content: |
      deb [signed-by=/usr/share/keyrings/google-cloud-archive-keyring.gpg]  cloud-sdk main
      
- name: add google sdk repository
  apt_repository:
    repo: "deb  cloud-sdk main"
    state: present

Getting error when creating the ubuntu 2404 image .

FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):
File "/tmp/ansible-tmp-1743068631.520732-94183-75803486625763/AnsiballZ_apt_repository.py", line 107, in
_ansiballz_main()
File "/tmp/ansible-tmp-1743068631.520732-94183-75803486625763/AnsiballZ_apt_repository.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/tmp/ansible-tmp-1743068631.520732-94183-75803486625763/AnsiballZ_apt_repository.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible.modules.apt_repository', init_globals=dict(_module_fqn='ansible.modules.apt_repository', _modlib_path=modlib_path),
File "", line 226, in run_module
File "", line 98, in _run_module_code
File "", line 88, in _run_code
File "/tmp/ansible_apt_repository_payload_lau7f97l/ansible_apt_repository_payload.zip/ansible/modules/apt_repository.py", line 679, in
File "/tmp/ansible_apt_repository_payload_lau7f97l/ansible_apt_repository_payload.zip/ansible/modules/apt_repository.py", line 656, in main
File "/usr/lib/python3/dist-packages/apt/cache.py", line 157, in init
self.open(progress)
File "/usr/lib/python3/dist-packages/apt/cache.py", line 214, in open
self._cache = apt_pkg.Cache(progress)
^^^^^^^^^^^^^^^^^^^^^^^
apt_pkg.Error: E:Conflicting values set for option Signed-By regarding source https://packages.cloud.google/apt/ cloud-sdk: /usr/share/keyrings/google-cloud-archive-keyring.gpg != , E:The list of sources could not be read.
Shared connection to 127.0.0.1 closed.", "module_stdout": "", "msg": "MODULE FAILURE
See stdout/stderr for the exact error", "rc": 1}

Using the below ansible tasks

    - name: Download the new Google Cloud GPG key
  shell: |
    curl -fsSL https://packages.cloud.google/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/google-cloud-archive-keyring.gpg
  args:
    creates: /usr/share/keyrings/google-cloud-archive-keyring.gpg

- name: Add Google Cloud repository to APT sources
  copy:
    dest: /etc/apt/sources.list.d/google-cloud.list
    content: |
      deb [signed-by=/usr/share/keyrings/google-cloud-archive-keyring.gpg] https://packages.cloud.google/apt cloud-sdk main
      
- name: add google sdk repository
  apt_repository:
    repo: "deb https://packages.cloud.google/apt cloud-sdk main"
    state: present
Share Improve this question edited Mar 27 at 14:01 Squashman 14.4k5 gold badges29 silver badges37 bronze badges asked Mar 27 at 10:09 DeepakDeepak 214 bronze badges 3
  • 2 The error Conflicting values set for option Signed-By suggests you may have a source set up for the google-cloud stuff already with a different signed-by value. – Richard Huxton Commented Mar 27 at 11:12
  • It was useful and I sorted the issue . When creating further the ubuntu image 2404 I faced issue in python , - name: install python libraries pip : name: "{{ ubuntu.python_dependencies }}" – Deepak Commented Mar 28 at 9:32
  • python_dependencies: - requests - apache-libcloud - google-auth - google-cloud-storage - gsutil - lxml - psutil - jinja2==3.0.3 , Error , "msg": "\n:stderr: error: externally-managed-environment\n\n× This environment is externally managed\n╰─> To install Python packages system-wide, try apt install\n python3-xyz, – Deepak Commented Mar 28 at 9:33
Add a comment  | 

1 Answer 1

Reset to default -1

added

    - name: Update package list
      apt:
        update_cache: yes


    - name: install google sdk
      apt:
        name: "google-cloud-sdk"
        install_recommends: no
        state: present
      register: result
      until: result is not failed
      retries: 5
      delay: 5

本文标签: google cloud platformubuntu 2404 image creation failure in creation using ansibleStack Overflow