I'm sure it's not limited to ansible, but I think there are times when you want to add a character string to the first line of a file such as a configuration file.
(It changes depending on the behavior in the order of setting in the configuration file)
Until now, I didn't really care about CentOS, but apparently it didn't work on OSX, so a memo at that time
And I noticed that @uraura's method was the simplest ...
~/.If the string you want to insert does not exist in zshrc.An example of adding a string to the first line of zshrc.[lineinfile](http://docs.ansible.com/ansible/lineinfile_module.html)Use modules
(And thanks to [@uraura](http://qiita.com/uraura) for teaching me)
#### **`/path/to/ansible-role/tasks/main.yml`**
```yaml
- name: Add .zshrc prezto.init.sh
lineinfile:
dest={{ ansible_env.HOME }}/.zshrc
line="source ~/.zsh/prezto.init.sh"
insertbefore=BOF state=present regexp="prezto\.init\.sh"
notify:
- execute source .zshrc
I was addicted to it for about an hour ...
Recommended Posts