Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2012 21:35
Show Gist options
  • Save anonymous/4262334 to your computer and use it in GitHub Desktop.
Save anonymous/4262334 to your computer and use it in GitHub Desktop.
Setting locale in an ansible play
[defaults]
hostfile = hosts
remote_user = vagrant
private_key_file = keys/id-vagrant
transport = ssh
forks = 1
$ ansible-playbook locale.yaml
PLAY [vagrant] *********************
TASK: [set locale to en_US.UTF-8] *********************
changed: [vagrant.nimbis.net]
PLAY [vagrant] *********************
TASK: [show locale and error out] *********************
failed: [vagrant.nimbis.net] => {"changed": true, "cmd": "locale && /bin/false ", "delta": "0:00:00.003105", "end": "2012-12-11 21:28:26.248887", "rc": 1, "start": "2012-12-11 21:28:26.245782"}
stdout: LANG=C
LANGUAGE=
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=en_US
FATAL: all hosts have already failed -- aborting
PLAY RECAP *********************
vagrant.nimbis.net : ok=1 changed=1 unreachable=0 failed=1
- hosts: vagrant
sudo: True
gather_facts: False
vars:
locale: en_US.UTF-8
tasks:
- name: set locale to $locale
command: /usr/sbin/update-locale LANG=$locale LC_ALL=$locale
- hosts: vagrant
gather_facts: False
tasks:
- name: show locale and error out
shell: locale && /bin/false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment