# - a sample / example of copying files from the controller to the managed nodes # - and/or updating files in place # # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/replace_module.html # https://docs.python.org/3/library/re.html # https://pythex.org/ # https://www.pythontutorial.net/python-regex/python-regex-backreferences/ # --- - name: copy 'hosts.allow' to node(s) ansible.builtin.copy: src: hosts.allow dest: "{{ backup_etc_dir }}/hosts.allow" owner: root group: root mode: '0644' tags: ['hosts.allow'] - name: copy 'hosts.deny' to node(s) ansible.builtin.copy: src: hosts.deny dest: "{{ backup_etc_dir }}/hosts.deny" owner: root group: root mode: '0644' tags: ['hosts.deny'] - name: Validate the sudoers file before saving ansible.builtin.lineinfile: path: "{{ backup_etc_dir }}/sudoers" state: present regexp: '^# %wheel ALL=\(ALL:ALL\) ALL' line: '%wheel ALL=(ALL:ALL) ALL' validate: /usr/sbin/visudo -cf %s tags: ['sudoers'] - name: copy 'rc.firewall' to node(s) ansible.builtin.copy: src: rc.firewall dest: "{{ backup_etc_dir }}/rc.firewall" owner: root group: root mode: '0755' tags: ['rc.firewall'] # can improve this w/ using ansibile facts to determine the os version - name: update slackpg mirror ansible.builtin.lineinfile: path: "{{ backup_etc_dir }}/mirrors" state: present # # slackware-current # regexp: '^# https://mirror.slackbuilds.org/slackware/slackware64-current/' # line: 'https://mirror.slackbuilds.org/slackware/slackware64-current/' # slackware-15.0 regexp: '^# https://mirror.slackbuilds.org/slackware/slackware64-15.0/' line: 'https://mirror.slackbuilds.org/slackware/slackware64-15.0/' tags: ['slackpkg_mirrors'] - name: update slackpg blacklist - blacklist kernels ansible.builtin.replace: path: "{{ backup_etc_dir }}/blacklist" regexp: '#kernel' replace: 'kernel' tags: ['slackpkg_blacklist_kernels'] - name: update slackpg blacklist - blacklist SBo packages ansible.builtin.replace: path: "{{ backup_etc_dir }}/blacklist" regexp: '#\[0-9\]' replace: '[0-9]' tags: ['slackpkg_blacklist_sbo'] # this will add a line to a file if it does not exist !! - name: update slackpg blacklist - blacklist alienbob packages ansible.builtin.lineinfile: path: "{{ backup_etc_dir }}/blacklist" search_string: '\[0-9\]\+alien' line: '[0-9]+alien' tags: ['slackpkg_blacklist_alien'] - name: update slackpg blacklist - blacklist sbopkg packages ansible.builtin.lineinfile: path: "{{ backup_etc_dir }}/blacklist" search_string: 'sbopkg' line: 'sbopkg' tags: ['slackpkg_blacklist_sbopkg'] - name: update slackpg blacklist - blacklist kde packages ansible.builtin.lineinfile: path: "{{ backup_etc_dir }}/blacklist" search_string: 'kde\/' line: 'kde/' tags: ['slackpkg_blacklist_kde']