Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung Nächste ÜberarbeitungBeide Seiten der Revision | ||
centos:ansible:basics [21.06.2020 16:18. ] – [Gourav Shah - Ansible Playbook Essentials] Abschnitt ergänzt django | centos:ansible:basics [28.06.2020 13:53. ] – [adhoc - Befehle] django | ||
---|---|---|---|
Zeile 340: | Zeile 340: | ||
==== Variablen ==== | ==== Variablen ==== | ||
- | Variablen in Playbooks sind der Verwendung von Variablen in jeder anderen Programmiersprache sehr ähnlich. Mit Hilfe von Variablen können wir einfach wiederkehrende Werteangaben einmal definieren und später reicht es dann jeweils auf diese Definition zu referenzieren. | + | Variablen in Playbooks sind der Verwendung von Variablen in jeder anderen Programmiersprache sehr ähnlich. Mit Hilfe von Variablen können wir einfach wiederkehrende Werteangaben einmal definieren und später reicht es dann jeweils auf diese Definition zu referenzieren. |
+ | |||
+ | Bei der Definition bzw.genauer gesagt bei der Wertezuweisung zu Variablen, stehen uns altbekannte Möglichkeiten aus diversen Programmiersprachen zur Verfügung. so können wir z.B. bei der Definition der Nodes **'' | ||
+ | * **catch all** : Auswahl aller Hosts durch **'' | ||
+ | * **Hostgruppe** : Wählt die im **inventory** definierte Hostgruppe: **'' | ||
+ | * **Teilmenge einer Hostgruppe**: | ||
+ | * **Ausschlussverfahren** : Einzelne Hosts aus einer Gruppe auszunehmen (exclude) ist natürlich auch einfach machbar. **'' | ||
+ | * **kombinierte Bereiche** : Natürlich ist es auch möglich, Kombinationen der obigen Definitionen anzuwenden, wie z.B.: **'' | ||
+ | |||
+ | Neben der Variablenzuweiseung | ||
So können wir zum Beispiel die Variable **'' | So können wir zum Beispiel die Variable **'' | ||
Zeile 781: | Zeile 790: | ||
$ ansible intranet -m yum -a "name = chrony state = latest" | $ ansible intranet -m yum -a "name = chrony state = latest" | ||
+ | ==== Module - Dokumentation ==== | ||
+ | Ansible bringt bei der Installation eine Vielzahl von Modulen, die sich im Verzeichnis **'' | ||
+ | |||
+ | Wie diese **[[https:// | ||
+ | |||
+ | Also entweder im Falle des Modules**dnf** die Webseite https:// | ||
+ | $ ansible-doc dnf | ||
+ | < | ||
+ | |||
+ | Installs, upgrade, removes, and lists packages and groups with the `dnf' package | ||
+ | manager. | ||
+ | |||
+ | * This module is maintained by The Ansible Core Team | ||
+ | OPTIONS (= is mandatory): | ||
+ | |||
+ | - allow_downgrade | ||
+ | Specify if the named package and version is allowed to downgrade a maybe already | ||
+ | installed higher version of that package. Note that setting allow_downgrade=True can | ||
+ | make this module behave in a non-idempotent way. The task could end up with a set of | ||
+ | packages that does not match the complete list of specified packages to install | ||
+ | (because dependencies between the downgraded package and others can cause changes to | ||
+ | the packages which were in the earlier transaction). | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - autoremove | ||
+ | If `yes', removes all " | ||
+ | dependencies of user-installed packages but which are no longer required by any such | ||
+ | package. Should be used alone or when state is `absent' | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - bugfix | ||
+ | If set to `yes', and `state=latest' | ||
+ | bugfix related. | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - conf_file | ||
+ | The remote dnf configuration file to use for the transaction. | ||
+ | [Default: (null)] | ||
+ | |||
+ | - disable_excludes | ||
+ | Disable the excludes defined in DNF config files. | ||
+ | If set to `all', disables all excludes. | ||
+ | If set to `main', | ||
+ | If set to `repoid', | ||
+ | [Default: (null)] | ||
+ | version_added: | ||
+ | |||
+ | - disable_gpg_check | ||
+ | Whether to disable the GPG checking of signatures of packages being installed. Has an | ||
+ | effect only if state is `present' | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | |||
+ | - disable_plugin | ||
+ | `Plugin' | ||
+ | not persist beyond the transaction. | ||
+ | [Default: (null)] | ||
+ | version_added: | ||
+ | |||
+ | - disablerepo | ||
+ | `Repoid' | ||
+ | not persist beyond the transaction. When specifying multiple repos, separate them with | ||
+ | a "," | ||
+ | [Default: (null)] | ||
+ | |||
+ | - download_dir | ||
+ | Specifies an alternate directory to store packages. | ||
+ | Has an effect only if `download_only' | ||
+ | [Default: (null)] | ||
+ | type: str | ||
+ | version_added: | ||
+ | |||
+ | - download_only | ||
+ | Only download the packages, do not install them. | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - enable_plugin | ||
+ | `Plugin' | ||
+ | persist beyond the transaction. | ||
+ | [Default: (null)] | ||
+ | version_added: | ||
+ | |||
+ | - enablerepo | ||
+ | `Repoid' | ||
+ | not persist beyond the transaction. When specifying multiple repos, separate them with | ||
+ | a "," | ||
+ | [Default: (null)] | ||
+ | |||
+ | - exclude | ||
+ | Package name(s) to exclude when state=present, | ||
+ | separated string. | ||
+ | [Default: (null)] | ||
+ | version_added: | ||
+ | |||
+ | - install_repoquery | ||
+ | This is effectively a no-op in DNF as it is not needed with DNF, but is an accepted | ||
+ | parameter for feature parity/ | ||
+ | [Default: yes] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - install_weak_deps | ||
+ | Will also install all packages linked by a weak dependency relation. | ||
+ | [Default: yes] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - installroot | ||
+ | Specifies an alternative installroot, | ||
+ | [Default: /] | ||
+ | version_added: | ||
+ | |||
+ | - list | ||
+ | Various (non-idempotent) commands for usage with `/ | ||
+ | playbooks. See examples. | ||
+ | [Default: (null)] | ||
+ | |||
+ | - lock_timeout | ||
+ | Amount of time to wait for the dnf lockfile to be freed. | ||
+ | [Default: 30] | ||
+ | type: int | ||
+ | version_added: | ||
+ | |||
+ | = name | ||
+ | A package name or package specifier with version, like `name-1.0' | ||
+ | state=latest, | ||
+ | or a local path to a rpm file. To operate on several packages this can accept a comma | ||
+ | separated string of packages or a list of packages. | ||
+ | (Aliases: pkg) | ||
+ | elements: str | ||
+ | type: list | ||
+ | |||
+ | - releasever | ||
+ | Specifies an alternative release from which all packages will be installed. | ||
+ | [Default: (null)] | ||
+ | version_added: | ||
+ | |||
+ | - security | ||
+ | If set to `yes', and `state=latest' | ||
+ | security related. | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - skip_broken | ||
+ | Skip packages with broken dependencies(devsolve) and are causing problems. | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - state | ||
+ | Whether to install (`present', | ||
+ | Default is `None', | ||
+ | `autoremove' | ||
+ | (Choices: absent, present, installed, removed, latest)[Default: | ||
+ | |||
+ | - update_cache | ||
+ | Force dnf to check if cache is out of date and redownload if needed. Has an effect only | ||
+ | if state is `present' | ||
+ | (Aliases: expire-cache)[Default: | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - update_only | ||
+ | When using latest, only update installed packages. Do not install packages. | ||
+ | Has an effect only if state is `latest' | ||
+ | [Default: no] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | - validate_certs | ||
+ | This only applies if using a https url as the source of the rpm. e.g. for localinstall. | ||
+ | If set to `no', the SSL certificates will not be validated. | ||
+ | This should only set to `no' used on personally controlled sites using self-signed | ||
+ | certificates as it avoids verifying the source site. | ||
+ | [Default: yes] | ||
+ | type: bool | ||
+ | version_added: | ||
+ | |||
+ | |||
+ | NOTES: | ||
+ | * When used with a `loop:` each package will be processed individually, | ||
+ | more efficient to pass the list directly to the `name` option. | ||
+ | * Group removal doesn' | ||
+ | upstream dnf's API doesn' | ||
+ | removal the module is unable to detect that the group is installed | ||
+ | (https:// | ||
+ | |||
+ | |||
+ | REQUIREMENTS: | ||
+ | |||
+ | AUTHOR: Igor Gnatenko (@ignatenkobrain) < | ||
+ | METADATA: | ||
+ | status: | ||
+ | - stableinterface | ||
+ | supported_by: | ||
+ | | ||
+ | |||
+ | EXAMPLES: | ||
+ | |||
+ | - name: install the latest version of Apache | ||
+ | dnf: | ||
+ | name: httpd | ||
+ | state: latest | ||
+ | |||
+ | - name: install the latest version of Apache and MariaDB | ||
+ | dnf: | ||
+ | name: | ||
+ | - httpd | ||
+ | - mariadb-server | ||
+ | state: latest | ||
+ | |||
+ | - name: remove the Apache package | ||
+ | dnf: | ||
+ | name: httpd | ||
+ | state: absent | ||
+ | |||
+ | - name: install the latest version of Apache from the testing repo | ||
+ | dnf: | ||
+ | name: httpd | ||
+ | enablerepo: testing | ||
+ | state: present | ||
+ | |||
+ | - name: upgrade all packages | ||
+ | dnf: | ||
+ | name: " | ||
+ | state: latest | ||
+ | |||
+ | - name: install the nginx rpm from a remote repo | ||
+ | dnf: | ||
+ | name: ' | ||
+ | state: present | ||
+ | |||
+ | - name: install nginx rpm from a local file | ||
+ | dnf: | ||
+ | name: / | ||
+ | state: present | ||
+ | |||
+ | - name: install the ' | ||
+ | dnf: | ||
+ | name: ' | ||
+ | state: present | ||
+ | |||
+ | - name: Autoremove unneeded packages installed as dependencies | ||
+ | dnf: | ||
+ | autoremove: yes | ||
+ | |||
+ | - name: Uninstall httpd but keep its dependencies | ||
+ | dnf: | ||
+ | name: httpd | ||
+ | state: absent | ||
+ | autoremove: no | ||
+ | |||
+ | - name: install a modularity appstream with defined stream and profile | ||
+ | dnf: | ||
+ | name: ' | ||
+ | state: present | ||
+ | |||
+ | - name: install a modularity appstream with defined stream | ||
+ | dnf: | ||
+ | name: ' | ||
+ | state: present | ||
+ | |||
+ | - name: install a modularity appstream with defined profile | ||
+ | dnf: | ||
+ | name: ' | ||
+ | state: present | ||
+ | |||
+ | </ | ||
===== Installation ===== | ===== Installation ===== |