Skip to content

Commit

Permalink
Merge pull request #28 from Oefenweb/add-an-option-to-import-timezone…
Browse files Browse the repository at this point in the history
…-info

Add an option to import timezone info
  • Loading branch information
tersmitten authored Nov 30, 2017
2 parents 78d75ab + bc383ec commit f681e44
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Set up a [percona-server](https://www.percona.com/software/mysql-database/percon
#### Requirements

* `python-mysqldb` (will be installed)
* `tee` (will not be installed)

#### Variables

Expand Down Expand Up @@ -74,6 +75,14 @@ Set up a [percona-server](https://www.percona.com/software/mysql-database/percon
* `percona_server_queries.{n}.database`: [required]: Name of the database to execute queries on
* `percona_server_queries.{n}.queries`: [default: `[]`]: A list of queries to execute

##### Timezone info

* `percona_server_zoneinfo_manage`: [default: `false`]: Whether or not to load time zone tables
* `percona_server_zoneinfo_tz_dir`: [default: `/usr/share/zoneinfo`]: The zoneinfo directory path name
* `percona_server_zoneinfo_tz_file`: [default: `''`]: The path of a single time zone file (e.g. `/usr/share/zoneinfo/Europe/Amsterdam`)
* `percona_server_zoneinfo_tz_name`: [default: `''`]: A time zone name (e.g. `Europe/Amsterdam`)
* `percona_server_zoneinfo_command`: [default: `mysql_tzinfo_to_sql {{ percona_server_zoneinfo_tz_dir }}`]: The zoneinfo command to generate SQL (e.g. `mysql_tzinfo_to_sql {{ percona_server_zoneinfo_tz_file }} {{ percona_server_zoneinfo_tz_name }}`, `mysql_tzinfo_to_sql --leap {{ {{ percona_server_zoneinfo_tz_file }} }}`)

## Dependencies

None
Expand Down
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ percona_server_users_absent_hosts:
- '%'

percona_server_queries: []

percona_server_zoneinfo_manage: false
percona_server_zoneinfo_tz_dir: /usr/share/zoneinfo
percona_server_zoneinfo_tz_file: ''
percona_server_zoneinfo_tz_name: ''
percona_server_zoneinfo_command: "mysql_tzinfo_to_sql {{ percona_server_zoneinfo_tz_dir }}"
7 changes: 7 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
- percona-server
- percona-server-toolkit-udfs

- include: zoneinfo.yml
tags:
- configuration
- percona-server
- percona-server-zoneinfo
when: percona_server_zoneinfo_manage | bool

- include: databases.yml
tags:
- configuration
Expand Down
19 changes: 19 additions & 0 deletions tasks/zoneinfo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# tasks file for percona-server
---
- name: timezone info | create (lock) directory
file:
path: "{{ percona_server_lock_path }}"
state: directory
owner: root
group: root
mode: 0755
tags:
- percona-server-zoneinfo-lock-directory

- name: timezone info | install
shell: >
{{ percona_server_zoneinfo_command }} | tee {{ percona_server_lock_path }}/zoneinfo.sql | mysql --database=mysql
args:
creates: "{{ percona_server_lock_path }}/zoneinfo.sql"
tags:
- percona-server-zoneinfo-install
2 changes: 2 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@
- database: mysql
queries:
- "INSERT IGNORE INTO user (Host, User, Password, ssl_type, ssl_cipher, x509_issuer, x509_subject) VALUES ('localhost', 'test', password('test'), '', '', '', '')"

percona_server_zoneinfo_manage: true

0 comments on commit f681e44

Please sign in to comment.