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

Role setting remote locale to same as local locale instead of var defined one #3

Closed
Migsi opened this issue Sep 14, 2021 · 4 comments
Closed

Comments

@Migsi
Copy link

Migsi commented Sep 14, 2021

Describe the bug

The role sets the remote machine to the same locale as the machine running ansible, instead of using var defined values. This seems weird, as the role performs no checks regarding the local locales, only the asertions are delegated to localhost, but that shouldn't impact values within vars. Is it possible there is some sort of variable collision (ansible magic var <> locale_lang)?

Playbook

See this issue for my playbook.

Output

I'll just paste the additional (verbose) output not shown in the above mentioned issue. Note that I am provisioning 2 hosts with this role, I just censored the actual domains of those servers, thats why you can see two ok: [my.remote.host] ... statements each. Also this was the second run of the play using the role, thats why there appear no changed statements.

TASK [robertdebock.locale : test if locale_lang is set correctly] *************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:3
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_language is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:10
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_address is set correctly] *******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:17
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_all is set correctly] ***********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:24
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_collate is set correctly] *******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:31
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_ctype is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:38
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_identification is set correctly] ************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:45
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_measurement is set correctly] ***************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:52
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_messages is set correctly] ******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:59
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_monetary is set correctly] ******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:66
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_name is set correctly] **********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:73
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_numeric is set correctly] *******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:80
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_paper is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:87
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_response is set correctly] ******************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:94
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_telephone is set correctly] *****************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:101
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_lc_time is set correctly] **********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:108
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : test if locale_timezone is set correctly] *********************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/assert.yml:115
ok: [my.remote.host -> localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

TASK [robertdebock.locale : install requirements] *****************************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/main.yml:9
ok: [my.remote.host] => {
    "cache_update_time": 1631618169,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "fail_on_autoremove": false,
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": [
                "locales-all",
                "tzdata"
            ],
            "only_upgrade": false,
            "package": [
                "locales-all",
                "tzdata"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    }
}
ok: [my.remote.host] => {
    "cache_update_time": 1631618170,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "fail_on_autoremove": false,
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": [
                "locales-all",
                "tzdata"
            ],
            "only_upgrade": false,
            "package": [
                "locales-all",
                "tzdata"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    }
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : configure locale.conf] ****************************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/main.yml:14
ok: [my.remote.host] => {
    "changed": false,
    "checksum": "c42aaf3c520136c2e7a944c2b8f66b538b4298f9",
    "dest": "/etc/default/locale",
    "diff": {
        "after": {
            "path": "/etc/default/locale"
        },
        "before": {
            "path": "/etc/default/locale"
        }
    },
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": "locale.conf.j2",
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "dest": "/etc/default/locale",
            "follow": true,
            "force": false,
            "group": null,
            "mode": "0644",
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "/etc/default/locale",
            "recurse": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "file",
            "unsafe_writes": false
        }
    },
    "mode": "0644",
    "owner": "root",
    "path": "/etc/default/locale",
    "size": 42,
    "state": "file",
    "uid": 0
}
ok: [my.remote.host] => {
    "changed": false,
    "checksum": "c42aaf3c520136c2e7a944c2b8f66b538b4298f9",
    "dest": "/etc/default/locale",
    "diff": {
        "after": {
            "path": "/etc/default/locale"
        },
        "before": {
            "path": "/etc/default/locale"
        }
    },
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": "locale.conf.j2",
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "dest": "/etc/default/locale",
            "follow": true,
            "force": false,
            "group": null,
            "mode": "0644",
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "/etc/default/locale",
            "recurse": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "file",
            "unsafe_writes": false
        }
    },
    "mode": "0644",
    "owner": "root",
    "path": "/etc/default/locale",
    "size": 42,
    "state": "file",
    "uid": 0
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
TASK [robertdebock.locale : set timezone] *************************************************************************************************************************************************************************
task path: /home/user/.ansible/roles/robertdebock.locale/tasks/main.yml:22
ok: [my.remote.host] => {
    "changed": false,
    "diff": {
        "after": {
            "name": "Europe/Vienna"
        },
        "before": {
            "name": "Europe/Vienna"
        }
    },
    "invocation": {
        "module_args": {
            "hwclock": null,
            "name": "Europe/Vienna"
        }
    }
}
ok: [my.remote.host] => {
    "changed": false,
    "diff": {
        "after": {
            "name": "Europe/Vienna"
        },
        "before": {
            "name": "Europe/Vienna"
        }
    },
    "invocation": {
        "module_args": {
            "hwclock": null,
            "name": "Europe/Vienna"
        }
    }
}
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
META: role_complete for my.remote.host
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
META: role_complete for my.remote.host
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'
Read vars_file 'vars/common.yml'
Read vars_file 'vars/authorized_keys.yml'
Read vars_file 'vars/gpg_keys.yml'

This is what the server says after the role ran:

~$ locale
LANG=de_AT.UTF-8
LANGUAGE=
LC_CTYPE="de_AT.UTF-8"
LC_NUMERIC="de_AT.UTF-8"
LC_TIME="de_AT.UTF-8"
LC_COLLATE="de_AT.UTF-8"
LC_MONETARY="de_AT.UTF-8"
LC_MESSAGES="de_AT.UTF-8"
LC_PAPER="de_AT.UTF-8"
LC_NAME="de_AT.UTF-8"
LC_ADDRESS="de_AT.UTF-8"
LC_TELEPHONE="de_AT.UTF-8"
LC_MEASUREMENT="de_AT.UTF-8"
LC_IDENTIFICATION="de_AT.UTF-8"
LC_ALL=

Before it was all set to C.UTF-8 which appears to be the default value within a proxmox ubuntu 20.04 container.

Environment

See this issue for my environment.

@robertdebock
Copy link
Owner

It's not easy to verify (molecule/default/verify.yml) this issue, bacause Ansible sets a default language.

I have tried to verify better however.

For your playbook, where does the de_AT.UTF-8 value come from? It does not come from the playbook (that uses the role) and it's also no the default... Is it maybe set for a specific user? Could it be that SSH is passing that variable from your machine to the managed server?

@Migsi
Copy link
Author

Migsi commented Sep 23, 2021

It's not easy to verify (molecule/default/verify.yml) this issue, bacause Ansible sets a default language.

This is probably set to de_AT.UTF-8, as that's the locale my notebook (the controller) is set to.

For your playbook, where does the de_AT.UTF-8 value come from? It does not come from the playbook (that uses the role) and it's also no the default... Is it maybe set for a specific user? Could it be that SSH is passing that variable from your machine to the managed server?

As I explained above, my notebook is set to this locale. As you suspected, I checked and noticed my ssh config is indeed forwarding the local locale. The server is configured to accept it. Are you suggesting to either disable reception on the server side or forwarding on my local machine and try again?
I'd prefer to leave these configs as it, as I'd have to check quite a few other tasks if they might be impacted by such changes. Just to get this right, what is the actual impact of ssh forwarding the locale setting while using this role? Shouldn't the locale change by the role be unaffected by any "outside" properties? That was my expectation when I started using the role and it worked fine, but please correct me if I got this wrong.

The overall behavior is weird though, as none of the related configs changed over time. The only thing that changed is that I updated ansible (to core 2.11.3) and the role to its most recent version (3.1.0). That's when the play broke and I started to see the reported behavior. That is why I suspected changes within ansible to be responsible, allthough I was unable to verify that (yet).

@Migsi
Copy link
Author

Migsi commented Sep 23, 2021

I guess I owe you an apology for bothering you again with issues that aren't actual issues. I just rechecked all locale related settings to make absolutely sure I wasn't misinterpreting something, but appearently I was. 🤦‍♂️

Your hint about ssh accepting the LC_* from the host logging pointed me to the curlprit. The servers default locale was always properly set to the value defined by locale_lang but as sshd is accepting remote locales it obviously looked to me as if the server was using the same locale as I do. When logging in via VNC everything was as it should always have been and thus the role never had an issue.

I'm still wondering though, why I didn't see this behavior before the above mentioned updates of ansible and the role. 🤔

I'll close the issue with a big thank you for taking your time helping me figuring out my (stupid) mistakes! 😅 I'll also open up a pull request adding information about this behavior to your readme, hoping it will prevent others from facing the same "problem".

@Migsi Migsi closed this as completed Sep 23, 2021
Migsi added a commit to Migsi/ansible-role-locale that referenced this issue Sep 23, 2021
As described within the issue robertdebock#3 I'd like to add hints about this SSH behavior to the readme.
@robertdebock
Copy link
Owner

Don't worry, I learn from these kinds of issues too. So far; your issue are certainly interesting.

Thanks for following up!

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

No branches or pull requests

2 participants