Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for re global flags expression #493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

talek
Copy link
Contributor

@talek talek commented Nov 7, 2024

Hello,

When trying to provision a new Oracle setup, the following error is raised:

TASK [opitzconsulting.ansible_oracle.orahost_meta : Extract SGA parameters, choose sga_max_size over sga_target if both are definied] ***
task path: /Users/talek/.ansible/collections/ansible_collections/opitzconsulting/ansible_oracle/roles/orahost_meta/tasks/main.yml:41 
Thursday 07 November 2024  18:43:16 +0200 (0:00:00.029)       0:00:12.053 *****                                                                                                                                                                                         
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: re.error: global flags not at the start of the expression at position 1
fatal: [mol-main-abc]: FAILED! => {"msg": "Unexpected failure during module execution: global flags not at the start of the expression at position 1", "stdout": ""}

It seems that Ansible/Python is picky and expects that the global (?i) option to be specified at the very beginning of the regex:

talek@MacBookPro ~ % ansible -m debug localhost -a "msg='{{ 'SGA_target' | regex_search('^(?i)sga_target$') }}'"
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: re.error: global flags not at the start of the expression at position 1
localhost | FAILED! => {
    "changed": false
}
talek@MacBookPro ~ % ansible -m debug localhost -a "msg='{{ 'SGA_target' | regex_search('(?i)^sga_target$') }}'"
localhost | SUCCESS => {
    "msg": "SGA_target"
}

@Rendanic Rendanic added the bug label Nov 17, 2024
@Rendanic Rendanic added this to the 4.11 milestone Nov 17, 2024
@talek
Copy link
Contributor Author

talek commented Nov 18, 2024

Some additional details. It depends apparently on the python version. For example, no problem with Python 3.9.18:

$ python3 -V
Python 3.9.18
$ ansible -m debug localhost -a "msg='{{ 'SGA_target' | regex_search('^(?i)sga_target$') }}'"
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
    "msg": "SGA_target"
}

But it fails with Python 3.12.7:

talek@mac ~ % python3 -V  
Python 3.12.7
talek@mac ~ % ansible -m debug localhost -a "msg='{{ 'SGA_target' | regex_search('^(?i)sga_target$') }}'"
[WARNING]: No inventory was parsed, only implicit localhost is available
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: re.error: global flags not at the start of the expression at position 1
localhost | FAILED! => {
    "changed": false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants