Mocking ansible in python 3?

Hello,
I read [why not to upgrade to Python 3? #1409]#1409).
I want write code as python 3-compitable. But when I use my code and try to see python 3.x problem’s I see:

Traceback (most recent call last):
  File "test_repository.py", line 19, in <module>
    from api.repository.repository import Repository
  File "/home.local/valerys/rde_1_3/rdepyui/tests/../api/repository/repository.py", line 2, in <module>
    import ansible.runner
  File "/usr/local/lib/python3.4/dist-packages/ansible/runner/__init__.py", line 402
    except errors.AnsibleError, e:
                              ^
SyntaxError: invalid syntax

Maybe there is project to move ansible on python 3? or some mock object? that I can use instead of ansible object?

Regards.

Hi,

Here you can find previous thread about python3: https://groups.google.com/d/topic/ansible-devel/Ez66CGHQQrM/discussion

To sum up py3 is planned to be supported by ansible v2.0, but core modules won’t drop py2.4 support anytime soon (beacause rhel5).

Regards
BlessJah

One clarification: 2.0 probably won’t support py3. But we are working to make the v2 code for the portion of ansible that runs locally to be compatible with py3; taking patches and fixing things that we run across as we work on other things. I just don’t anticipate that the work to allow ansible to run on python 3 will be finished by the time 2.0 is released.

During the pycon sprints several people worked on python 3 support (ianzd, momandine, dorianpula, rory_finnegan) and fixes were merged for low hanging fruit such as the exception syntax.

As Michal notes, the modules are a harder problem to solve. Our plan is to get the portion of ansible that runs on the controlling machine running on python 3+ python 2.6/2.7 and then see what technique would make the most sense for supporting python2.4+ and python 3.x in the modules.

-Toshio

I'm curious to know what's driving the desire to support RHEL5 at this
point. Red Hat will consider it "production" at least until March 2017,
but what about the actual installed base running Ansible? Is Ansible,
Inc. deriving enough revenue from RHEL5 customer to justify the pressure
on testing and development?

I feel Ansible v2 would be a good point in time to break away with
Python 2.4. I'm not sure people running RHEL5 are really looking forward
to implementing the latest Ansible code anyways (so no impact to them).
I believe it would be easier to keep some version on long-term support
basis (serious bugs and security fixes) as a paid product than to hold
everything behind because of, what seems to me, a small percentage of
users.

Giovanni

Correction on one point. RHEL is in an extended support phase right now and customers will simply pay more to use RHEL5 for the next decade or all time regardless of the advertised end of support dates.

https://access.redhat.com/support/policy/updates/errata#Life_Cycle_Dates

It has more to do with the ansible OSS user base (which does include
Ansible inc clients), they still file tickets about 2.4 compatibility,
as a very recent example, for the known_hosts module.

You'd be surprised who many people are stuck with older infrastructure
and really depend on Ansible to bring some sanity into their world (at
least I hope it does).