Repository navigation
Expand file tree
/
Copy pathmako.yaml
More file actions
143 lines (126 loc) · 4.38 KB
/
Copy pathmako.yaml
File metadata and controls
143 lines (126 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Ansible Playbook for Building and Running the Mako Server
#
# Quick Start: Installing Ansible
# Run this on your development machine (Debian/Ubuntu):
# sudo apt update && sudo apt install ansible -y
#
# Local Machine Example:
# Compile, install, and run tutorials on your own machine:
# ansible-playbook -i localhost, -c local mako.yaml -e install=true -e tutorials=true
#
# Remote Target Example:
# Compile, install, and run tutorials on a remote machine:
# ansible-playbook -i 192.168.1.146, -u debian mako.yaml -e install=true -e tutorials=true
# (Replace 192.168.1.146 with your target's IP address and debian with your target username)
#
# Optional Flags:
# -e install=true # Install Mako Server to /usr/local/bin
# -e tutorials=true # Run Lua tutorial scripts (requires install)
#
# Accessing the Tutorials:
# If tutorials are enabled, open a browser and go to:
# - http://localhost (for local run)
# - http://<target-ip> (for remote run)
#
# Detailed documentation: Ansible.md
---
- name: Build and optionally install Mako Server
hosts: all
vars:
required_packages:
- git
- zip
- unzip
- gcc
- make
sqldir: "2026"
sqlver: "3510300"
mako_install_path: "/usr/local/bin"
builddir: "makobuild"
install: false
tutorials: false
tasks:
- name: Ensure base directory exists
file:
path: "{{ builddir }}"
state: directory
- name: Ensure required packages are installed
become: true
apt:
name: "{{ required_packages }}"
state: present
when: ansible_os_family == 'Debian'
- name: Clone BAS repository if not present
git:
repo: https://github.com/RealTimeLogic/BAS.git
dest: "{{ builddir }}/BAS"
update: yes
force: no
register: basrepo
- name: Clone BAS-Resources repository if not present
git:
repo: https://github.com/RealTimeLogic/BAS-Resources.git
dest: "{{ builddir }}/BAS-Resources"
update: yes
force: yes
- name: Make build scripts in BAS-Resources executable
file:
path: "{{ builddir }}/BAS-Resources/build"
recurse: yes
mode: "u+x"
when: ansible_os_family == 'Debian'
- name: Clone LPeg if not present
git:
repo: https://github.com/roberto-ieru/LPeg.git
dest: "{{ builddir }}/LPeg"
update: yes
- name: Clone lua-protobuf if not present
git:
repo: https://github.com/starwing/lua-protobuf.git
dest: "{{ builddir }}/lua-protobuf"
update: yes
- name: Clone CBOR if not present
git:
repo: https://github.com/spc476/CBOR.git
dest: "{{ builddir }}/CBOR"
update: yes
- name: Check if sqlite3.c exists
stat:
path: "{{ builddir }}/BAS/src/sqlite3.c"
register: sqlite_stat
- name: Download SQLite amalgamation
get_url:
url: "https://www.sqlite.org/{{sqldir}}/sqlite-amalgamation-{{sqlver}}.zip"
dest: "/tmp/sqlite-amalgamation-{{sqlver}}.zip"
when: not sqlite_stat.stat.exists
- name: Unzip SQLite
unarchive:
src: "/tmp/sqlite-amalgamation-{{sqlver}}.zip"
dest: "/tmp"
remote_src: yes
when: not sqlite_stat.stat.exists
- name: Move SQLite files to BAS/src
shell: mv /tmp/sqlite-amalgamation-{{sqlver}}/* {{ builddir }}/BAS/src/
when: not sqlite_stat.stat.exists
- name: Compile Mako Server
shell: |
make -f mako.mk clean
echo "n" | make -f mako.mk
args:
chdir: "{{ builddir }}/BAS"
when: basrepo.changed
- name: Install Mako Server binary
become: yes
shell: cp -f {{ builddir }}/BAS/mako {{ mako_install_path }}/mako && chmod 0755 {{ mako_install_path }}/mako
when: install
- name: Install Mako zip file
become: yes
shell: cp -f {{ builddir }}/BAS/mako.zip {{ mako_install_path }}/mako.zip && chmod 0644 {{ mako_install_path }}/mako.zip
when: install
- name: Run Lua tutorials
become: yes
shell: |
killall mako || true
{{ mako_install_path }}/mako -u {{ lookup('env', 'USER') }} -d -l::{{ builddir }}/BAS-Resources/tools/MakoDownloadTutorials
ignore_errors: yes
when: tutorials