GithubHelp home page GithubHelp logo

robertdebock / ansible-role-locale Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 8.0 214 KB

Configure locale on your system.

Home Page: https://robertdebock.nl/

License: Apache License 2.0

Jinja 100.00%
ansible locale molecule playbook system tox

ansible-role-locale's Introduction

A creative nerd

I like nerding-out, specifically around Ansible and Terraform automated test and infrastucture.

Always willing to help, love to learn and work with people.

Anurag's github stats

ansible-role-locale's People

Contributors

hollow avatar pandvan avatar philippwaller avatar robert-de-bock avatar robertdebock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-role-locale's Issues

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

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.

Undefined attributes in dict

Describe the bug

To begin with, I'm unsure if this is a bug or just happens because I'm doing it wrong.

When trying to provision a remote Ubuntu LXC on a Proxmox Host, the role immediately fails with the error fatal: [my.remote.host -> localhost]: FAILED! => {"msg": "'dict object' has no attribute 'password'"}

Playbook

I just paste the part of the playbook relating to locale(s), which is within our "common" role, as setting the locale is one of the things that needs to be done on all of our hosts.

...
  # Locale role
- name: Change locale using external role
  include_role:
    name: robertdebock.locale
...

Our config done via group_vars/all.yml:

...
# Default locale configuration
locale_lang: en_GB.UTF-8
locale_timezone: Europe/Vienna
...

Our requirements.yml which is fed into ansible before every run:

roles:
  - name: robertdebock.bootstrap
    version: 5.2.3

  - name: robertdebock.locale
    version: 3.1.0
...
collections:
...

Output

The first "TASK" in the output is the line calling the role, as described above.

...
TASK [Change locale using external role] **************************************************************************************************************************************************************************

TASK [robertdebock.locale : test if locale_lang is set correctly] *************************************************************************************************************************************************
fatal: [my.remote.host -> localhost]: FAILED! => {"msg": "'dict object' has no attribute 'password'"}
...

Environment

  • Control node OS: NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)"
  • Control node Ansible version: ansible [core 2.11.3]
  • Managed node OS: NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)" actually just a LXC on a Proxmox 6.4-13 Host (Debian 10)

Lack of idempotency on Debian

Describe the bug

The role set the chosen locale(s) in /etc/default/locale surrounding them with double quotes.

cat /etc/default/locale
#
# Ansible managed
#

LANG="en_US.UTF-8"

On Debian distributions the handler then executes the command update-locale LANG=en_US.UTF-8 that cause double quotes to be removed.

Maybe we could use localectl also on Debian 11, as it is shipped by systemd package.

Playbook

- hosts: all
  gather_facts: no
  become: no

  vars:
    # https://github.com/robertdebock/ansible-role-locale/blob/master/defaults/main.yml
    locale_timezone: Europe/Rome

  tasks:
    - ansible.builtin.setup:
        filter:
          - ansible_os_family
          - ansible_distribution

    - ansible.builtin.import_role:
        name: robertdebock.locale

Output

Every execution after the first show this diff

--- before: /etc/default/locale
+++ after: /Users/_redacted_/.ansible/tmp/ansible-local-8260libc5m2z/tmpbk5uok4j/locale.conf.j2
@@ -1,4 +1,5 @@
 #
 # Ansible managed
 #
-LANG=en_US.UTF-8
+
+LANG="en_US.UTF-8"

Environment

  • Control node OS: MacOS 10.15
  • Control node Ansible version: ansible-core 2.11.7
  • Managed node OS: Debian 11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.