- 📜 9 Ansible плейбуков примеров для администрирования Windows
- Копирование файлов
- Установить / удалить MSI
- Удалить программное обеспечение (.EXE)
- Остановить / запустить / перезапустить службу Windows
- Сбор фактов
- Запуск команд
- Переменные среды
- Изменить реестр
- Удаление логов
- Добавить комментарий Отменить ответ
- • Свежие записи
- • Категории
- • itsecforu.ru
- • Страны посетителей
- IT is good
- ansible.builtin.copy – Copy files to remote locations¶
- Synopsis¶
- Parameters¶
- Notes¶
- See Also¶
- Examples¶
- Return Values¶
- win_copy — Copies files to remote locations on windows hosts¶
- Synopsis¶
- Options¶
- Examples¶
- Return Values¶
- Notes¶
- Status¶
- Maintenance Info¶
- ansible.windows.win_copy – Copies files to remote locations on windows hosts¶
- Synopsis¶
- Parameters¶
- Notes¶
- See Also¶
- Examples¶
- Return Values¶
- 📜 9 Ansible плейбуков примеров для администрирования Windows
- Копирование файлов
- Установить / удалить MSI
- Удалить программное обеспечение (.EXE)
- Остановить / запустить / перезапустить службу Windows
- Сбор фактов
- Запуск команд
- Переменные среды
- Изменить реестр
- Удаление логов
- Добавить комментарий Отменить ответ
- • Свежие записи
- • Категории
- • itsecforu.ru
- • Страны посетителей
- IT is good
📜 9 Ansible плейбуков примеров для администрирования Windows
Я предполагаю, что вы уже установили Ansible на Windows и вы хотите управлять серверами Windows.
Ниже приведены некоторые из наиболее часто используемых задач, выполняемых администраторами Windows ежедневно. Вы будете удивлены, увидев, как легко администрируется Windows с помощью Ansible.
IP-адрес моего компьютера с контроллером Ansible Windows – 192.168.0.106, а IP-адрес моей удаленной системы Windows – 192.168.0.102
Мое соединение с удаленным хостом прошло успешно.
Копирование файлов
win_copy – это модуль, который копирует файл с локального сервера на удаленный хост Windows.
Я буду использовать этот модуль для копирования одного PDF.
Используйте приведенный ниже код YAML, укажите исходный и целевой путь.
Установить / удалить MSI
state present означает, что MSI будет установлен на машине, и приложение будет находится в текущем состоянии.
Здесь я устанавливаю Apache.
Теперь перейдите в систему Windows и проверьте, успешно ли установлено приложение apache.
Ниже приведен тот же пример, что и выше, но вместо state мы используем аргумент install для установки apache.
Чтобы удалить приложение с помощью файла MSI, вам нужно использовать модуль win_package.
Отсутствие state absent, что приложение будет удалено с использованием файла MSI.
Здесь я удаляю Apache.
Запустите ansible плейбук для удаления MSI
Теперь, если я проверю версию apache, я получу следующий вывод, так как приложение было удалено.
Удалить программное обеспечение (.EXE)
Вы также можете удалить программное обеспечение с помощью файла .exe, используя идентификатор продукта этого программного обеспечения (product id).
Остановить / запустить / перезапустить службу Windows
Модуль win_service используется для запуска, остановки или перезапуска службы. Здесь я покажу вам, как остановить службу tomcat.
Запустите ansible плейбук, чтобы остановить службу Tomcat.
Сбор фактов
С помощью модуля ansible win_disk_facts вы можете получить всю информацию о диске целевого хоста.
Используя ANSI-модуль win_command, вы можете выполнять команды на удаленном хосте, получать информацию о процессоре, сведения об устройстве и многое другое.
Запуск команд
Какие бы команды вы ни выполняли в Windows, они могут выполняться через модуль ansible win_command.
Вам просто нужно указать команду в вашем файле YAML.
На примере я просто создаю каталог.
Переменные среды
Система Windows имеет несколько переменных среды, например, JAVA_HOME.
Используя ANSI-модуль win_environment, вы можете добавлять или изменять переменные среды в системе Windows.
В этом примере я добавляю новую переменную в список переменных среды Windows.
Изменить реестр
Ansible модуль win_regedit используется для добавления или редактирования данных реестра на удаленной машине с Windows.
Вам необходимо указать путь к реестру и контент для добавления / обновления.
Здесь я создаю новую запись реестра Itisgood по пути HKLM:\SOFTWARE, а затем добавляю имя и данные в этот реестр.
Запустите ansible плейбук, чтобы добавить именения в реестр.
Удаление логов
Модуль win_eventlog используется для добавления, очистки или удаления логов системы Windows.
Перейдите в Windows Powershell и перечислите EventLogs, присутствующие на удаленном компьютере с Windows.
Теперь, если вы снова перечислите логи, вы увидите, что логи Internet Explorer были удалены.
Добавить комментарий Отменить ответ
• Свежие записи
• Категории
• itsecforu.ru
• Страны посетителей
IT is good
ansible.builtin.copy – Copy files to remote locations¶
This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name copy even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
Synopsis¶
The copy module copies a file from the local or remote machine to a location on the remote machine.
Use the ansible.builtin.fetch module to copy files from remote locations to the local box.
If you need variable interpolation in copied files, use the ansible.builtin.template module. Using a variable in the content field will result in unpredictable output.
For Windows targets, use the ansible.windows.win_copy module instead.
This module has a corresponding action plugin .
Parameters¶
Parameter | Choices/ Defaults | Comments | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameter | required | default | choices | comments |
---|---|---|---|---|
content |
Examples¶
Return Values¶
Common return values are documented here Return Values , the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
checksum | success, src is a file | string | 6e642bb8dd5c2e027bf21dd923337cbb4214f827 | |
dest | changed | string | C:\Temp\ | |
operation | success | string | file_copy | |
original_basename | changed, src is a file | string | foo.txt | |
size | changed, src is a file | int | 1220 | |
src | changed | string | /home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source |
Notes¶
- For non-Windows targets, use the copy module instead.
- Currently win_copy does not support copying symbolic links from both local to remote and remote to remote.
- It is recommended that backslashes \ are used instead of / when dealing with remote paths.
- Because win_copy runs over WinRM, it is not a very efficient transfer mechanism. If sending large files consider hosting them on a web service and using win_get_url instead.
Status¶
This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
Maintenance Info¶
For more information about Red Hat’s this support of this module, please refer to this knowledge base article
For help in developing on modules, should you be so inclined, please read Community Information & Contributing , Testing Ansible and Developing Modules .
Copyright © 2017 Red Hat, Inc.
Last updated on Dec 01, 2020.
Ansible docs are generated from GitHub sources using Sphinx using a theme provided by Read the Docs. . Module documentation is not edited directly, but is generated from the source code for the modules. To submit an update to module docs, edit the ‘DOCUMENTATION’ metadata in the modules directory of the core source code repository.
ansible.windows.win_copy – Copies files to remote locations on windows hosts¶
This plugin is part of the ansible.windows collection (version 1.4.0).
To install it use: ansible-galaxy collection install ansible.windows .
To use it in a playbook, specify: ansible.windows.win_copy .
Synopsis¶
The win_copy module copies a file on the local box to remote windows locations.
For non-Windows targets, use the ansible.builtin.copy module instead.
This module has a corresponding action plugin .
Parameters¶
Parameter | Choices/ Defaults | Comments |
---|---|---|