Ansible добавить apt_key - PullRequest
       15

Ansible добавить apt_key

0 голосов
/ 16 июня 2019

В чем может быть проблема с файлом задачи?

эта роль должна делать это:

  1. добавить ключ apt для vscodium

  2. добавить vscodium репозиторий

  3. установить vscodium

Когда я хочу использовать ansible $ansible-playbook /etc/ansible/ubuntu_real.yml эта ошибка отображается:

heavy  ~  ansible-playbook /etc/ansible/ubuntu_real.yml
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

 [WARNING]: Ignoring invalid attribute: repo

 [WARNING]: Ignoring invalid attribute: state


PLAY [localhost] **************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [localhost]

TASK [ubuntu_real : Add an Apt signing key for vscodium] **********************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (apt_key) module: become, become_method Supported parameters include: data, file, id, key, keyring, keyserver, state, url, validate_certs"}
 [WARNING]: Could not create retry file '/etc/ansible/ubuntu_real.retry'.         [Errno 13] Permission denied: u'/etc/ansible/ubuntu_real.retry'


PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1  

файл задач для / etc / ansible / role / ubuntu_real содержит ошибку apt_key

---
# tasks file for /etc/ansible/roles/ubuntu_real

################################################################
# Resouces
################################################################
# install apt 
# https://docs.ansible.com/ansible/latest/modules/apt_module.html
# add apt_repository
# https://docs.ansible.com/ansible/latest/modules/apt_repository_module.html
################################################################


################################################################
# Vscodium
################################################################
- name: Add an Apt signing key for vscodium
  apt_key:
    url: https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg
    state: present
    become: yes
    become_method: "sudo"

# vscodium add repo
- apt_repository:
  repo: deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main
  state: present
  become: yes
  become_method: "sudo"

- name: install vscodium
  apt:
    name: vscodium
    update_cache: yes
    become: yes
    become_method: "sudo"
################################################################

файл для запуска роли /etc/ansible/ubuntu_real.yml

---
- hosts: localhost
  connection: local
  roles:
  - ubuntu_real

1 Ответ

0 голосов
/ 16 июня 2019

Неподдерживаемые параметры для модуля (apt_key): становиться, стать_методом

Поддерживаемые параметры включают в себя: данные, файл, идентификатор, ключ, набор ключей, сервер ключей, состояние, URL, validate_certs

Это потому, что become: является ключевым словом Task, а не ключевым словом module . Вы ошиблись в своем ямле; должно быть:

- name: Add an Apt signing key for vscodium
  apt_key:
    url: https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg
    state: present
  become: yes
  become_method: "sudo"
...