관리-도구
편집 파일: apt_repository.cpython-39.opt-1.pyc
a �)g�q � @ sr d dl mZmZmZ eZdZdZdZd dl Z d dl Z d dlZd dlZd dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZmZmZ d dlmZ d d lmZ d d lmZ z,d dlZd dlZd dl m!Z" e"�#� Z!dZ$W n( e%�y d Z Z Z"Z!dZ$Y n0 g d �Z&dZ'dZ(dd� Z)G dd� de*�Z+G dd� de,�Z-G dd� de-�Z.dd� Z/dd� Z0e1dk�rne0� dS )� )�absolute_import�division�print_functiona� --- module: apt_repository short_description: Add and remove APT repositories description: - Add or remove an APT repositories in Ubuntu and Debian. extends_documentation_fragment: action_common_attributes attributes: check_mode: support: full diff_mode: support: full platform: platforms: debian notes: - This module supports Debian Squeeze (version 6) as well as its successors and derivatives. options: repo: description: - A source string for the repository. type: str required: true state: description: - A source string state. type: str choices: [ absent, present ] default: "present" mode: description: - The octal mode for newly created files in sources.list.d. - Default is what system uses (probably 0644). type: raw version_added: "1.6" update_cache: description: - Run the equivalent of C(apt-get update) when a change occurs. Cache updates are run after making changes. type: bool default: "yes" aliases: [ update-cache ] update_cache_retries: description: - Amount of retries if the cache update fails. Also see I(update_cache_retry_max_delay). type: int default: 5 version_added: '2.10' update_cache_retry_max_delay: description: - Use an exponential backoff delay for each retry (see I(update_cache_retries)) up to this max delay in seconds. type: int default: 12 version_added: '2.10' validate_certs: description: - If C(false), SSL certificates for the target repo will not be validated. This should only be used on personally controlled sites using self-signed certificates. type: bool default: 'yes' version_added: '1.8' filename: description: - Sets the name of the source list file in sources.list.d. Defaults to a file name based on the repository source url. The .list extension will be automatically added. type: str version_added: '2.1' codename: description: - Override the distribution codename to use for PPA repositories. Should usually only be set when working with a PPA on a non-Ubuntu target (for example, Debian or Mint). type: str version_added: '2.3' install_python_apt: description: - Whether to automatically try to install the Python apt library or not, if it is not already installed. Without this library, the module does not work. - Runs C(apt-get install python-apt) for Python 2, and C(apt-get install python3-apt) for Python 3. - Only works with the system Python 2 or Python 3. If you are using a Python on the remote that is not the system Python, set I(install_python_apt=false) and ensure that the Python apt library for your Python version is installed some other way. type: bool default: true author: - Alexander Saltanov (@sashka) version_added: "0.7" requirements: - python-apt (python 2) - python3-apt (python 3) - apt-key or gpg a! - name: Add specified repository into sources list ansible.builtin.apt_repository: repo: deb http://archive.canonical.com/ubuntu hardy partner state: present - name: Add specified repository into sources list using specified filename ansible.builtin.apt_repository: repo: deb http://dl.google.com/linux/chrome/deb/ stable main state: present filename: google-chrome - name: Add source repository into sources list ansible.builtin.apt_repository: repo: deb-src http://archive.canonical.com/ubuntu hardy partner state: present - name: Remove specified repository from sources list ansible.builtin.apt_repository: repo: deb http://archive.canonical.com/ubuntu hardy partner state: absent - name: Add nginx stable repository from PPA and install its signing key on Ubuntu target ansible.builtin.apt_repository: repo: ppa:nginx/stable - name: Add nginx stable repository from PPA and install its signing key on Debian target ansible.builtin.apt_repository: repo: 'ppa:nginx/stable' codename: trusty - name: One way to avoid apt_key once it is removed from your distro block: - name: somerepo |no apt key ansible.builtin.get_url: url: https://download.example.com/linux/ubuntu/gpg dest: /etc/apt/trusted.gpg.d/somerepo.asc - name: somerepo | apt source ansible.builtin.apt_repository: repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/myrepo.asc] https://download.example.com/linux/ubuntu {{ ansible_distribution_release }} stable" state: present �#N)� AnsibleModule)� has_respawned�probe_interpreters_for_module�respawn_module)� to_native)�PY3)� fetch_urlTF)z/etc/apt/keyringsz/etc/apt/trusted.gpg.dz/usr/share/keyringsi� )Zdebzdeb-srcc C s� | j s�| �d�}|r�| �|dg�\}}}|dkrH| jd||�� f d� | �|d|ddg�\}}}|dkr�| jd||�� f d� n| jd | d� d S ) Nzapt-get�updater z*Failed to auto-install %s. Error was: '%s'��msg�installz-yz-qz&%s must be installed to use check mode)� check_mode�get_bin_path�run_command� fail_json�strip)�module�apt_pkg_nameZapt_get_path�rcZsoZse� r �B/usr/lib/python3.9/site-packages/ansible/modules/apt_repository.py�install_python_apt� s r c @ s e Zd ZdS )� InvalidSourceN)�__name__� __module__�__qualname__r r r r r � s r c @ s� e Zd Zdd� Zdd� Zdd� Zdd� Zd$d d�Zedd � �Z edd� �Z dd� Zdd� Zdd� Z dd� Zd%dd�Zdd� Zd&dd�Zd d!� Zd"d#� ZdS )'�SourcesListc C sb || _ i | _t� | _| �d�| _tj�| j�r:| � | j� t �d| �d� �D ]}| � |� qNd S )NzDir::Etc::sourcelistz %s/*.list�Dir::Etc::sourceparts) r �files�set� new_repos� _apt_cfg_file�default_file�os�path�isfile�load�globZiglob�_apt_cfg_dir)�selfr �filer r r �__init__� s zSourcesList.__init__c c s@ | j �� D ]0\}}|D ]"\}}}}}|r|||||fV qq dS )zeSimple iterator to go over all sources. Empty, non-source, and other not valid lines will be skipped.N)r"