blockinfile no longer works in 2.1.0 (maybe eariler version, too)

90 views
Skip to first unread message

Scott Worthington

unread,
May 31, 2016, 10:20:59 AM5/31/16
to Ansible Project
Hello,

I'm testing ansible 2.1.0.0 built from the git repo.
The actual installed RPM package on CentOS 7.2.1511 is 
ansible-2.1.0.0-0.git201605271344.2452bd2.stable21.el7.centos.noarch

I'm trying to use blockinfile.

My basic playbook named test-blockinfile.yml has:

---
- hosts: localhost
  connection: local
  gather_facts: no

  tasks:

  - name: A very simple blockinfile test
    blockinfile:
      dest: ~/testfile
      insertbefore: BOF
      block: |
        This is my block
        This should work
        It is very basic test
      create: yes


Executing it with ansible-playbook -vvv test-blockinfile.yml results in:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_lq3WNb/ansible_module_blockinfile.py", line 311, in <module>
    main()
  File "/tmp/ansible_lq3WNb/ansible_module_blockinfile.py", line 247, in main
    if module.constants['ANSIBLE_VERSION'].startswith('1.'):
AttributeError: 'AnsibleModule' object has no attribute 'constants'

Can anyone else confirm that they are getting the error, too?

I've submitted 2348: https://github.com/ansible/ansible-modules-extras/issues/2348

Thank you.



Kai Stian Olstad

unread,
May 31, 2016, 10:48:31 AM5/31/16
to ansible...@googlegroups.com
On 31. may 2016 16:19, Scott Worthington wrote:
> Can anyone else confirm that they are getting the error, too?

Your playbook is working for me on Kubuntu 16.04 and
ansible 2.1.0.0 (detached HEAD 2452bd2135)
lib/ansible/modules/core: (detached HEAD 21ef499e04)
lib/ansible/modules/extras: (detached HEAD b19948181d)

--
Kai Stian Olstad

Scott Worthington

unread,
Jun 5, 2016, 9:39:03 AM6/5/16
to Ansible Project

I pulled down ansible via git repository to create an RPM via:

$ git clone git://github.com/ansible/ansible.git --recursive
$ cd ./ansible
$ git pull --rebase

However, I did not do the following:

$ git submodule update --init --recursive

From the section http://docs.ansible.com/ansible/intro_installation.html#running-from-source:
"Note when updating ansible, be sure to not only update the source tree,
but also the “submodules” in git which point at Ansible’s own modules
(not the same kind of modules, alas)."

After performing the above, then building and installing the RPM, the blockinfile module works.

$ make rpm
$ sudo rpm -Uvh ./rpm-build/ansible-*.noarch.rpm

Hopefully this helps someone else, too.
Reply all
Reply to author
Forward
0 new messages