![]() The book describes several strategies for porting to Python 3. Is Lennart Regebro’s book: Porting to Python 3. The best place to start learning about writing code that supports both Python 2 and Python 3 Developing Ansible code that supports Python 2 and Python 3 Your custom modules can support any version of Python (or other languages) you want, but the above are the requirements for the code contributed to the Ansible project. See Control Node Requirements and Managed Node Requirements for the Minimum version of Python 3.x and Python 2.x If you’re developing a module or some module_utils code, be sure to read the section on string strategy carefully. However, the three types of code do not use the same string strategy. Shared module_utils code needs to support the same range of Python as the modules. Shared module_utils code - the common code that is used by modules to perform tasks and sometimes used by controller-side code as well. Modules need to support the ‘managed node’ Python versions, with some exceptions. Modules - the code which Ansible transmits to and invokes on the managed machine. We do have some considerations depending on the types of Ansible code:Ĭontroller-side code - code that runs on the machine where you invoke /usr/bin/ansible, only needs to support the controller’s Python versions. Use str.format() for Python 2.6 compatibility Import Ansible’s bundled Python six library Tips, tricks, and idioms for Python 2/Python 3 compatibility Unicode Sandwich common borders: places to convert bytes to text in controller code Understanding strings in Python 2 and Python 3Ĭontroller string strategy: the Unicode Sandwich Minimum version of Python 3.x and Python 2.xĭeveloping Ansible code that supports Python 2 and Python 3 Controlling how Ansible behaves: precedence rules.Virtualization and Containerization Guides.Migrating Roles to Roles in Collections on Galaxy.The lifecycle of an Ansible module or plugin.Tips, tricks, and idioms for Python 2/Python 3 compatibility.Unicode Sandwich common borders: places to convert bytes to text in controller code.Understanding strings in Python 2 and Python 3.Developing Ansible code that supports Python 2 and Python 3.Minimum version of Python 3.x and Python 2.x.Contributing your module to an existing Ansible collection.Protecting sensitive data with Ansible vault.
0 Comments
Leave a Reply. |