Member-only story

Edit single line text — Ansible module lineinfile

How to edit a single-line text in a file with Ansible module lineinfile customize your /etc/ssh/sshd_config.

Luca Berton
4 min readSep 6, 2021

Today we’re going to talk about how to edit a single-line text in a file with Ansible.

Ansible module lineinfile.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot

Ansible module lineinfile

Today we’re talking about the Ansible module lineinfile.

The full name is ansible.builtin.lineinfile, which means that is part of the collection of modules “builtin” with ansible and shipped with it.

It’s a module pretty stable and out for years and it supports a large variety of operating systems.

You are able to insert, update and remove a single line of text in a file.

Main Parameters

  • path string — file path
  • line string — text
  • insertafter/insertbefore string — EOF/regular expression
  • validate string — validation command

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet