Advertisement
UHLHosting

tried_it

Oct 21st, 2022
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.24 KB | None | 0 0
  1. ---
  2. - name: Replace line in file examples
  3.   hosts: test
  4.  
  5.   vars:
  6.     strings:
  7.      - 1
  8.       - 0
  9.  
  10.   tasks:
  11.     - name: Find the files
  12.       become: true
  13.       become_user: root
  14.       ansible.builtin.find:
  15.         paths: /usr/local/apnscp/resources/templates/plans/basic/
  16.         file_type: file
  17.         recurse: yes
  18.         patterns:
  19.          - bandwidth
  20.           - cpu
  21.           - aliases
  22.           - auth
  23.           - billing
  24.           - crontab
  25.           - dns
  26.           - ftp
  27.           - ipinfo6
  28.           - logs
  29.           - metrics
  30.           - mysql
  31.           - rampart
  32.           - siteinfo
  33.           - ssh
  34.           - tomcat
  35.           - vacation
  36.           - apache
  37.           - bandwidth
  38.           - cgroup
  39.           - diskquota
  40.           - files
  41.           - ipinfo
  42.           - logrotate
  43.           - mail
  44.           - mlist
  45.           - pgsql
  46.           - reseller
  47.           - spamfilter
  48.           - ssl
  49.           - users
  50.         use_regex: true
  51.       register: plans
  52.  
  53.     - name: Replace strings in files found
  54.       ansible.builtin.replace:
  55.         dest: "{{ item.path }}"
  56.         backup: yes
  57.         regexp: '^enabled'
  58.         replace: "enabled {{ strings }}"
  59.       with_items: "{{ my_find.files }}"
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement