permite trabajar con ficheros, plantillas y directorios
los módulos para OpenSSL:
https://docs.ansible.com/ansible/latest/modules/copy_module.html#copy-module
- name: copiar configuración copy: src=apache2.conf dest=/etc/apache2/apache2.conf owner=www-data group=www-data - name: crear contenido en fichero copy: content="Mi contenido en un fichero" dest=/etc/mi.conf
https://docs.ansible.com/ansible/latest/modules/template_module.html#template-module
- name: copiar pantilla de configuración template: src=apache2.conf.j2 dest=/etc/apache2/apache2.conf backup=yes
https://docs.ansible.com/ansible/latest/modules/file_module.html#file-module
... tasks: - name: propiedades del fichero file: path="/path/al/fichero" backup=yes mode="777" - name: borrar el fichero file: path="/path/al/fichero" backup=yes absent=yes - name: verificar que directorio existe file: path: "/path/to/directory" state: directory owner: root group: systemd-journal mode: 2755 notify: reiniciar_journald handlers: - name: reiniciar_journald service: name=systemd-journald state=restarted
https://docs.ansible.com/ansible/latest/modules/stat_module.html#stat-module
- name: obtener datos de fichero stat: path="/path/to/file" register: datos_fichero - name: mostrar información debug: var=datos_fichero - name: en condicional debug: msg="es diretorio" when: datos.stat.isdir # o cualauier otro atributo
https://docs.ansible.com/ansible/latest/modules/fetch_module.html#fetch-module
- name: copiar configuración red fetch: src=/etc/network/interfaces dest=/tmp/backup
https://docs.ansible.com/ansible/latest/modules/unarchive_module.html#unarchive-module
- name: copiar y extraer fichero en remoto unarchive: src=<file.tgz> dest=/opt/fichero -name: extraer en remoto fichero ya existente allí unarchive: src=<file.tgz> dest=/opt/fichero remote_src=true
https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html#lineinfile-module
- name: deshabilita SELinux lineinfile: dest=/etc/selinux/config regexp='^SELINUX=' line='SELINUX=disabled' - name: eliminar la línea que permite al grupo wheel del fichero de configuración de sudoers lineinfile: dest=/etc/sudoers state=absent regexp="^wheel" - name: añadir antes de una línea lineinfile: dest=/etc/apache2/ports.conf regexp='^Listen' insertafter="Listen 80" line="Listen 8080"
https://docs.ansible.com/ansible/latest/modules/blockinfile_module.html#blockinfile-module
- name: asegurar que el texto está en el fichero dest: /etc/ssh/sshd_config block: | Match user monitor Password Authentication no
- name: instalar módulo phyton requerido apt: name=phyton-openssl state=latest - name: generar clave privada openssl_privatekey: path=/etc/ssl/private/private.pem
- name: generar clave pública openssl_publickey: path: /etc/ssl/private/public.key privatekey_path: /etc/ssl/private/private.pem