-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVEMENT] Upgrade unison binaries, improve installations method, …
…reorganize unison roles
- Loading branch information
Showing
22 changed files
with
218 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
unison_project_name: "{{ mageops_project }}" | ||
unison_project_slug: "{{ unison_project_name | trim | lower | regex_replace('[^a-z0-9]+', '_') }}" | ||
|
||
unison_server_port: "{{ mageops_unison_server_port | default(5566) }}" | ||
unison_server_address: "{{ hostvars[groups['vagrant'][0]]['ansible_host'] }}" | ||
|
||
# Skip installation, just set up the project configuration | ||
unison_project_skip_install: no | ||
|
||
unison_project_local_path: "{{ playbook_dir }}/../projects/{{ unison_project_name }}" | ||
unison_project_remote_path: "/{{ unison_project_name }}" | ||
|
||
unison_project_config_dir: ~/.unison | ||
unison_project_config_path: "{{ unison_project_config_dir }}/{{ unison_project_name }}.prf" | ||
|
||
unison_project_ignore_names: | ||
- ".idea" | ||
- ".history" | ||
- ".DS_Store" | ||
- "._.DS_Store" | ||
- "node_modules" | ||
- ".php_cs.cache" | ||
- ".tmp" | ||
- "*.log" | ||
|
||
unison_project_ignore_paths: | ||
- "var/cache" | ||
- "var/view_preprocessed" | ||
- "var/log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies: | ||
- role: cs.unison | ||
when: not unison_project_skip_install | default(False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- name: Create unison config dir | ||
file: | ||
path: "{{ unison_project_config_dir }}" | ||
state: directory | ||
|
||
- name: Ensure local project dir exsits | ||
file: | ||
path: "{{ unison_project_local_path }}" | ||
state: directory | ||
|
||
- name: Create unison profile | ||
template: | ||
src: project.prf | ||
dest: "{{ unison_project_config_path }}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
root={{ unison_project_local_path | realpath }} | ||
root=socket://{{ unison_server_address }}:{{ unison_server_port }}{{ unison_project_remote_path }} | ||
label=Autoconfig for raccoon project {{ unison_project_name }} | ||
|
||
auto=true | ||
batch=true | ||
fastcheck=default | ||
retry=3 | ||
|
||
|
||
group=false | ||
owner=false | ||
dontchmod=false | ||
perms=777 | ||
prefer={{ unison_project_local_path | realpath }} | ||
silent=false | ||
repeat=watch | ||
stream=true | ||
|
||
ignoreinodenumbers=true | ||
ignorelocks=true | ||
|
||
ignore = Name {{ '{' }}{{ unison_project_ignore_names | join(',') }}{{ '}' }} | ||
ignore = Path {{ '{' }}{{ unison_project_ignore_paths | join(',') }}{{ '}' }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
unison_project_name: "{{ mageops_project }}" | ||
|
||
unison_server_port: "{{ mageops_unison_server_port | default(5566) }}" | ||
|
||
unison_server_version: 2.48.4 | ||
unison_server_tarball_url: "http://www.cis.upenn.edu/~bcpierce/unison/download/releases/unison-{{ unison_server_version }}/unison-{{ unison_server_version }}.tar.gz" | ||
|
||
unison_server_user_create: yes | ||
unison_server_user: "{{ magento_user }}" | ||
unison_server_group: "{{ magento_group }}" | ||
|
||
unison_server_working_dir: "{{ mageops_app_web_dir }}" | ||
unison_server_project_dir: "{{ unison_server_working_dir }}/{{ unison_project_name }}" | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dependencies: | ||
- cs.unison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
- name: Create user | ||
when: unison_server_user_create | ||
user: | ||
name: "{{ unison_server_user }}" | ||
state: present | ||
|
||
- name: Ensure directories exist | ||
file: | ||
dest: "{{ item }}" | ||
state: directory | ||
mode: 0775 | ||
owner: "{{ unison_server_user }}" | ||
group: "{{ unison_server_group }}" | ||
with_items: | ||
- "{{ unison_server_working_dir }}" | ||
- "{{ unison_server_project_dir }}" | ||
|
||
- name: Install unison service file | ||
template: | ||
src: unison.service | ||
dest: /etc/systemd/system | ||
notify: restart unison | ||
|
||
- name: Start and enable unison | ||
service: | ||
name: unison | ||
state: started | ||
enabled: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
unison_macos_brew_package: unison | ||
unison_macos_brew_package_fsmonitor: autozimu/homebrew-formulas/unison-fsmonitor | ||
unison_linux_inotify_max_user_watches: 1000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies: | ||
- role: cs.repo-mageops | ||
when: ansible_distribution | lower == 'centos' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- name: <CentOS> Increase max inotify watches for unison | ||
sysctl: | ||
name: fs.inotify.max_user_watches | ||
value: "{{ unison_linux_inotify_max_user_watches | string }}" | ||
reload: yes | ||
state: present | ||
|
||
- name: <CentOS> Make sure conflicting packages are absent | ||
yum: | ||
name: unison | ||
state: absent | ||
|
||
- name: <CentOS> Install latest unison version from MageOps RPM repo | ||
yum: | ||
name: unison-static | ||
state: latest | ||
enablerepo: mageops |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
- name: <macOS> Check if homebrew package manager is present | ||
command: brew config | ||
failed_when: no | ||
register: unison_brew_config_command | ||
|
||
- name: <macOS> Warn user about being unable to install | ||
when: unison_brew_config_command is failed | ||
fail: | ||
msg: | | ||
==================================================================== | ||
= WARNING! Unison will NOT be installed! = | ||
==================================================================== | ||
Automated installation on macOS requires that you have a functional | ||
homebrew package manager installed. | ||
Please go to https://brew.sh/ and follow the setup instructions. | ||
Once you're done you can retry running this action or install them | ||
manually: | ||
$ brew install {{ unison_macos_brew_package_fsmonitor }} {{ unison_macos_brew_package }} | ||
- name: <macOS> Install unison using homebrew | ||
when: unison_brew_config_command is success | ||
homebrew: | ||
state: present | ||
name: | ||
- "{{ unison_macos_brew_package }}" | ||
- "{{ unison_macos_brew_package_fsmonitor }}" | ||
install_options: | ||
- --force | ||
- --force-bottle | ||
|
||
# Homebrew module doesn't allow specifying link options | ||
- name: <macOS> Make sure unison binaries are linked properly | ||
when: unison_brew_config_command is success | ||
command: >- | ||
brew link --overwrite | ||
{{ unison_macos_brew_package }} | ||
{{ unison_macos_brew_package_fsmonitor }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
- name: Fail with warning about unspported OS | ||
when: ansible_distribution | lower not in ['macosx', 'centos'] | ||
fail: | ||
msg: | | ||
==================================================================== | ||
= WARNING! Unison will not be installed! = | ||
==================================================================== | ||
Automated installation is supported only on macOS and CentOS and your | ||
system has been identified as: {{ ansible_distribution }} | ||
You will have to install unison and fsmonitor manually yourself | ||
to get continous file sync. | ||
- name: Install unison client for macOS | ||
import_tasks: install-macos.yml | ||
when: ansible_distribution | lower == 'macosx' | ||
|
||
- name: Install unison client for CentOS | ||
import_tasks: install-centos.yml | ||
when: ansible_distribution | lower == 'centos' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# Run this playbook with --ask-sudo-pass | ||
- hosts: "all" | ||
# Best run this playbook with --ask-sudo-pass | ||
- hosts: vagrant | ||
become: yes | ||
gather_facts: yes | ||
roles: | ||
- role: cs.unison-guest | ||
- role: cs.unison-server | ||
|
||
- hosts: localhost | ||
connection: local | ||
gather_facts: yes | ||
roles: | ||
- role: cs.unison-host | ||
- role: cs.unison-project |
Oops, something went wrong.