- name: Install the latest version of Apache from the testing repo ansible.builtin.yum: name: httpd enablerepo: testing state: present
- name: Install one specific version of Apache ansible.builtin.yum: name: httpd-2.2.29-1.4.amzn1 state: present
- name: Upgrade all packages ansible.builtin.yum: name: '*' state: latest
- name: Upgrade all packages, excluding kernel & foo related packages ansible.builtin.yum: name: '*' state: latest exclude: kernel*,foo*
- name: Install the nginx rpm from a remote repo ansible.builtin.yum: name: http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm state: present
- name: Install nginx rpm from a local file ansible.builtin.yum: name: /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm state: present
- name: Install the 'Development tools' package group ansible.builtin.yum: name: "@Development tools" state: present
- name: Install the 'Gnome desktop' environment group ansible.builtin.yum: name: "@^gnome-desktop-environment" state: present
- name: List ansible packages and register result to print with debug later ansible.builtin.yum: list: ansible register: result
- name: Install package with multiple repos enabled ansible.builtin.yum: name: sos enablerepo: "epel,ol7_latest"
- name: Install package with multiple repos disabled ansible.builtin.yum: name: sos disablerepo: "epel,ol7_latest"
- name: Download the nginx package but do not install it ansible.builtin.yum: name: - nginx state: latest download_only: true
Déployer des packages avec apt
Gérer des packages APT dans les distributions Linux basées sur .DEB :
- name: Install the package "foo" ansible.builtin.apt: name: foo
- name: Install a list of packages ansible.builtin.apt: pkg: - foo - foo-tools
- name: Install the version '1.00' of package "foo" ansible.builtin.apt: name: foo=1.00
- name: Update the repository cache and update package "nginx" to latest version using default release squeeze-backport ansible.builtin.apt: name: nginx state: latest default_release: squeeze-backports update_cache: yes
- name: Install the version '1.18.0' of package "nginx" and allow potential downgrades ansible.builtin.apt: name: nginx=1.18.0 state: present allow_downgrade: yes
- name: Install zfsutils-linux with ensuring conflicted packages (e.g. zfs-fuse) will not be removed. ansible.builtin.apt: name: zfsutils-linux state: latest fail_on_autoremove: yes
- name: Install latest version of "openjdk-6-jdk" ignoring "install-recommends" ansible.builtin.apt: name: openjdk-6-jdk state: latest install_recommends: no
- name: Update all packages to their latest version ansible.builtin.apt: name: "*" state: latest
- name: Upgrade the OS (apt-get dist-upgrade) ansible.builtin.apt: upgrade: dist
- name: Run the equivalent of "apt-get update" as a separate step ansible.builtin.apt: update_cache: yes
- name: Only run "update_cache=yes" if the last one is more than 3600 seconds ago ansible.builtin.apt: update_cache: yes cache_valid_time: 3600
- name: Pass options to dpkg on run ansible.builtin.apt: upgrade: dist update_cache: yes dpkg_options: 'force-confold,force-confdef'
- name: Install a .deb package ansible.builtin.apt: deb: /tmp/mypackage.deb
- name: Install the build dependencies for package "foo" ansible.builtin.apt: pkg: foo state: build-dep
- name: Install a .deb package from the internet ansible.builtin.apt: deb: https://example.com/python-ppq_0.1-1_all.deb
- name: Remove useless packages from the cache ansible.builtin.apt: autoclean: yes
- name: Remove dependencies that are no longer required ansible.builtin.apt: autoremove: yes
- name: Run the equivalent of "apt-get clean" as a separate step apt: clean: yes
Déployer sur Windows
Gérer des logiciels pour Windows. Les fichiers pris en charge sont de type .exe, .msi, .msp, .appx, .appxbundle, .msix et .msixbundle :
- name: Install the Visual C thingy ansible.windows.win_package: path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}' arguments: /install /passive /norestart
- name: Install Visual C thingy with list of arguments instead of a string ansible.windows.win_package: path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}' arguments: - /install - /passive - /norestart
- name: Uninstall Remote Desktop Connection Manager from local MSI omitting the product_id ansible.windows.win_package: path: C:\temp\rdcman.msi state: absent
# 7-Zip exe doesn't use a guid for the Product ID - name: Install 7zip from a network share with specific credentials ansible.windows.win_package: path: \\domain\programs\7z.exe product_id: 7-Zip arguments: /S state: present become: yes become_method: runas become_flags: logon_type=new_credential logon_flags=netcredentials_only vars: ansible_become_user: DOMAIN\User ansible_become_password: Password
- name: Install 7zip and use a file version for the installation check ansible.windows.win_package: path: C:\temp\7z.exe creates_path: C:\Program Files\7-Zip\7z.exe creates_version: 16.04 state: present
- name: Uninstall 7zip from the exe ansible.windows.win_package: path: C:\Program Files\7-Zip\Uninstall.exe product_id: 7-Zip arguments: /S state: absent
- name: Uninstall 7zip without specifying the path ansible.windows.win_package: product_id: 7-Zip arguments: /S state: absent
- name: Enable installation of 3rd party MSIX packages ansible.windows.win_regedit: path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock name: AllowAllTrustedApps data: 1 type: dword state: present
- name: Install an MSIX package for the current user ansible.windows.win_package: path: C:\Installers\Calculator.msix # Can be .appx, .msixbundle, or .appxbundle state: present
- name: Uninstall an MSIX package using the product_id ansible.windows.win_package: product_id: InputApp state: absent