kharandziuk
kharandziuk

Reputation: 12890

How to set shell variable in ansible globally

I had a problem with locales on vagrant described in other question.

For fixing this problem I need to set environment variable:

export LC_ALL="en_US.UTF-8"

Is there a way to do that globally for playbook?

Upvotes: 1

Views: 3942

Answers (1)

300D7309EF17
300D7309EF17

Reputation: 24573

I ran into this same problem with Postgres and Vagrant and Ansible. Here's how I solved it.

- name: dev locale
  action: command sudo update-locale LC_ALL=en_US.UTF-8
- name: set default locale
  sudo: yes
  lineinfile: dest=/etc/default/locale
    regexp="LC_ALL"
    line="LC_ALL=\"en_US.UTF-8\""

Yes, the command sudo line is weird. But it works.

Upvotes: 5

Related Questions