{"account":{"acct":"brozek","avatar":"https://cdn.fosstodon.org/accounts/avatars/108/219/415/927/856/966/original/bae9f46f23936e79.jpg","display_name":"Brandon Rozek","header":"https://fosstodon.org/headers/original/missing.png","id":"108219415927856966","uri":"https://fosstodon.org/users/brozek","url":"https://fosstodon.org/@brozek","username":"brozek"},"application":null,"card":{"author_name":"","author_url":"","blurhash":null,"description":"Two of my favorite functions in Ansible are lineinfile and blockinfile. They are extraordinarily useful when one needs to ensure that a line or a block is either replaced or put in a config file.\nlineinfile # For example, let's say one wants to enable IP forwarding in the sysctl, one can write the following task in Ansible:\n- name: Enable IP forwarding lineinfile: dest: /etc/sysctl.conf regexp: \"net.ipv4.ip_forward\" line: \"net.ipv4.ip_forward=1\" state: present What exactly this task does is:","embed_url":"","height":0,"html":"","image":null,"image_description":"","language":"en","provider_name":"","provider_url":"","published_at":null,"title":"Poor man's Ansible: lineinfile and blockinfile in bash","type":"link","url":"https://kkovacs.eu/ansible-lineinfile-blockinfile-in-bash/","width":0},"content":"
Kristof Kovacs wrote a script that emulates lineinfile from Ansible.
Now I don't need to open up a whole text editor to edit one line in a configuration file.
","date":"2023-09-19T20:05:54.023Z","edited_at":null,"emojis":[],"favourites_count":1,"id":"111093609530864980","in_reply_to_account_id":null,"in_reply_to_id":null,"language":"en","media_attachments":[],"mentions":[],"poll":null,"reblog":null,"reblogs_count":0,"replies_count":0,"sensitive":false,"spoiler_text":"","syndication":"https://fosstodon.org/@brozek/111093609530864980","tags":[],"visibility":"public"}