Thursday, April 21, 2016

git commit and the error: There was a problem with the editor 'vi'.

Error message:

error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.


Quick solution:

git config --global core.editor $(which vim)

Short-reason: If you are using vundler, or similar, you could find this error.
Issue: https://github.com/VundleVim/Vundle.vim/issues/167

Monday, April 11, 2016

'include:' statement in Ansible does not find the correct path running on Vagrant

What is the issue?

You have a include statement inside a role but when the playbook is running on Vagrant, that path doesn't exist!!

Tree:

├── playbook.yml
└── roles
    ├── base
    │   ├── README.md
    │   ├── defaults
    │   │   └── main.yml
    │   ├── files
    │   ├── handlers
    │   │   └── main.yml
    │   ├── meta
    │   │   └── main.yml
    │   ├── tasks
    │   │   ├── main.yml
    │   │   ├── setup_debian.yml
    │   │   └── setup_rhel.yml
    │   ├── templates
    │   └── vars
    │       └── main.yml


In tasks/main.yml we have:

- name: Trying to update base installation on RedHat
  include: setup_rhel.yml
  when: ansible_os_family == 'RedHat'

- name: Trying to update base installation on Debian
  include: setup_debian.yml
  when: ansible_os_family == 'Debian'


If you run the playbook.yml in a Vagrant box you could see this error message:

FAILED! => {"failed": true, "reason": "the file_name '/Users/vicente/vagrant/ansible/playbooks/setup_debian.yml' does not exist, or is not readable"}

Well, this is the new tasks/main.yml to solve it:

---
# Include OS-specific installation tasks.
- name: Trying to update base installation on RedHat
  include: "{{ role_path }}/tasks/setup_rhel.yml"
  when: ansible_os_family == 'RedHat'

- name: Trying to update base installation on Debian
  include: "{{ role_path }}/tasks/setup_debian.yml"
  when: ansible_os_family == 'Debian
'

:)