Taula de continguts

Windows

3:41 Windows (I)

win_command

https://docs.ansible.com/ansible/latest/modules/win_command_module.html#win-command-module

-name: quien soy
 hosts: windows01
 tasks:
  - win_command: whoami
    register: usuario
  - debug: var=usuario

win_copy

https://docs.ansible.com/ansible/latest/modules/win_copy_module.html#win-copy-module

...
- name: copiar fichero
  win_copy:
    src: config.txt
    dest: c:\config.txt

win_file

https://docs.ansible.com/ansible/latest/modules/win_file_module.html#win-file-module

- name: crear estructura de directorios
  win_file:
    path: c:\users\alberto\Documents\apache2\conf
    state: directory

win_lineinfile

https://docs.ansible.com/ansible/latest/modules/win_lineinfile_module.html#win-lineinfile-module

...
- name: editar puerto
  win_lineinfile:
    path: c:\httpd.conf
    state: present
    line: Listen 8080
    regexp: "^Listen"

3:42 Windows (II)

win_service

https://docs.ansible.com/ansible/latest/modules/win_service_module.html#win-service-module

- name: reiniciar servicio
  win_service:
    name: spooler
    start_mode: manual
    state: stopped

win_shell

https://docs.ansible.com/ansible/latest/modules/win_shell_module.html#win-shell-module

name: ejecutar script
  win_shell: c:\script.ps1
    args:
      chdir: c:\

win_template

https://docs.ansible.com/ansible/latest/modules/win_template_module.html#win-template-module

j2 = jinga2

- name: copiar plantilla
  win_template:
   src: info.j2
   dest: c:\info.txt

win_user

https://docs.ansible.com/ansible/latest/modules/win_user_module.html#win-user-module

-name: crear usuario
  win_user:
    name: oforte
    password: oforte123
    state: present
    groups:
      - users