Skip to content

Commit a2626a1

Browse files
authored
Merge pull request #44 from saint-hilaire/rc/v2.2
Rc/v2.2
2 parents d0495d4 + 971ea7e commit a2626a1

24 files changed

+703
-133
lines changed

CONTRIBUTING.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Lampsible Contributing Guidelines
2+
3+
Thank you for your interest in Lampsible. This document will help to make it easier
4+
for you to contribute code.
5+
6+
## Setting up your development environment
7+
8+
Something like this should work:
9+
10+
```bash
11+
python -m venv .venv
12+
. .venv/bin/activate
13+
python -m pip install -e .
14+
```
15+
16+
## Branching guidelines
17+
18+
All code changes are made through pull requests via the latest develop branch, currently `dev/v2`.
19+
Though not strictly required, it would be a big help if you name your topic branch
20+
something like `feature/gh-9-some-github-issue` or `bugfix/gh-10-other-github-issue`,
21+
and include that branch name into the header line of your commit message, something like this:
22+
```bash
23+
feature/gh-9-some-github-issue
24+
25+
- Implement the feature like this or that.
26+
```
27+
28+
29+
## Unit tests
30+
31+
If possible, please include unit tests for your changes. If you simply add it to
32+
_test/test_lampsible.py_, that should probably be fine.
33+
34+
However, unit tests are a bit tricky in Lampsible. To run the tests, you need to
35+
provide an actual host on which Lampsible can install whatever it is you're trying to test.
36+
And as a word of caution, will install public facing web apps with insecure passwords!
37+
For this reason, unit tests are optional - if you omit this, I'll take care of it myself.
38+
At any rate, the easiest way to run the tests is to do something like this:
39+
40+
```
41+
42+
# These 2 aren't super important, if you omit them, the
43+
# Laravel tests will simply be skipped.
44+
export LAMPSIBLE_LARAVEL_NAME=my-laravel-app
45+
export LAMPSIBLE_LARAVEL_PATH=/path/to/my-laravel-app-2.0.tar.gz
46+
python -m unittest
47+
```
48+
49+
Lampsible will install various things onto the host specified by `LAMPSIBLE_REMOTE`, so beware!
50+
This server should be insensitive in that regard. Also, Lampsible will set insecure passwords
51+
on that server, so again, beware! You should tear down that server after running tests.
52+
53+
Also, if you run the whole test suite, at some point, the test
54+
will "fail" on the "Ansible side" because of some edge case
55+
related to Composer packages, caused by a non empty
56+
`composer_working_directory`. This is not really a problem.
57+
Lampsible is not intended to install Drupal, WordPress, etc, alongside
58+
each other on the same host. So to really run these tests, you
59+
should run them one at a time
60+
( `python -m unittest test.test_lampsible.TestLampsible.test_wordpress`, etc. ),
61+
and rebuild the server after each test case.
62+
63+
The nature of Ansible automations - it requires some real remote server -
64+
poses a unique challenge with regards to unit tests. However,
65+
in spite of this little drawback, these tests are still quite convenient
66+
when you change the code but want to make sure nothing breaks.

README.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -207,43 +207,3 @@ If you want something similar with Docker, consider using [Docksible](https://gi
207207
another project that I maintain. It will install a web app onto your remote server with Docker Compose.
208208
It also leverages Ansible locally under the hood.
209209

210-
## Contributing
211-
212-
Please do! I'd be more than happy to see Issues, Pull Requests and any other kind of feedback ;-)
213-
214-
### Running unit tests
215-
216-
```
217-
218-
# These 2 aren't super important, if you omit them, the
219-
# Laravel tests will simply be skipped.
220-
export LAMPSIBLE_LARAVEL_NAME=my-laravel-app
221-
export LAMPSIBLE_LARAVEL_PATH=/path/to/my-laravel-app-2.0.tar.gz
222-
python -m unittest
223-
```
224-
225-
Lampsible will install various things onto the host specified by `LAMPSIBLE_REMOTE`, so beware!
226-
This server should be insensitive in that regard. Also, Lampsible will set insecure passwords
227-
on that server, so again, beware! You should tear down that server after running tests.
228-
229-
Also, these tests should be taken with a grain of salt. They are not true unit tests,
230-
When Lampsible runs, it calls Ansible playbooks under the hood, and when those playbooks
231-
finish running, Lampsible returns a status code of 0, no matter what happens on the
232-
remote server. And this status code is what the tests ultimately check.
233-
So when you run tests, you have to actually keep an eye on the console output
234-
printed by Ansible, as well as the results on your remote server.
235-
236-
Also, if you run the whole test suite, at some point, the test
237-
will "fail" on the "Ansible side" because of some edge case
238-
related to Composer packages, caused by a non empty
239-
`composer_working_directory`. This is not really a problem.
240-
Lampsible is not intended to install Drupal, WordPress, etc, alongside
241-
each other on the same host. So to really run these tests, you
242-
should run them one at a time
243-
( `python -m unittest test.test_lampsible.TestLampsible.test_wordpress`, etc. ),
244-
and rebuild the server after each test case.
245-
246-
The nature of Ansible automations - it requires some real remote server -
247-
poses a unique challenge with regards to unit tests. However,
248-
in spite of this little drawback, these tests are still quite convenient
249-
when you change the code but want to make sure nothing breaks.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "lampsible"
10-
version = "2.1.2"
10+
version = "2.2.0"
1111
authors = [
1212
{name="Brian St. Hilaire", email="[email protected]"}
1313
]

src/lampsible/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.1.2'
1+
__version__ = '2.2.0'

src/lampsible/arg_validator.py

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,32 @@ def validate_database_args(self):
195195

196196
default_database_names = {
197197
'wordpress': 'wordpress',
198-
'joomla': 'joomla',
199-
'drupal': 'drupal',
200-
'laravel': self.args.app_name,
198+
'joomla' : 'joomla',
199+
'drupal' : 'drupal',
200+
'laravel' : self.args.app_name,
201+
'suitecrm' : 'suitecrm',
201202
}
202203

203204
default_database_table_prefixes = {
204205
'wordpress': 'wp_',
205206
# TODO?
206-
'joomla': '',
207-
'drupal': '',
208-
'laravel': '',
207+
'joomla' : '',
208+
'drupal' : '',
209+
'laravel' : '',
210+
'suitecrm' : '',
209211
}
210-
if self.args.database_password \
211-
and not self.args.insecure_cli_password:
212212

213+
if self.args.database_username == 'root':
214+
print(dedent("""
215+
'root' is an invalid database username. You probably want to
216+
rerun this command with '--ask-database-root'.
217+
"""))
218+
return 1
219+
220+
if (
221+
self.args.database_password \
222+
or self.args.database_root_password \
223+
) and not self.args.insecure_cli_password:
213224
print(INSECURE_CLI_PASS_WARNING)
214225
return 1
215226

@@ -218,6 +229,7 @@ def validate_database_args(self):
218229
'joomla',
219230
'drupal',
220231
'laravel',
232+
'suitecrm',
221233
]:
222234
self.handle_defaults([
223235
{
@@ -239,6 +251,14 @@ def validate_database_args(self):
239251
},
240252
], True, True)
241253

254+
if self.args.ask_database_root_password \
255+
and not self.validated_args.database_root_password:
256+
self.validated_args.database_root_password = self.get_pass_and_check(
257+
'Please enter a database root password: ',
258+
0,
259+
True
260+
)
261+
242262
if self.validated_args.database_username and not self.validated_args.database_password:
243263
self.validated_args.database_password = self.get_pass_and_check(
244264
'Please enter a database password: ',
@@ -281,6 +301,12 @@ def validate_ssl_args(self):
281301

282302
def validate_php_args(self):
283303

304+
if self.args.php_version:
305+
print(dedent("""
306+
Warning! '--php-version' has been deprecated, and will be
307+
removed in v3.
308+
"""))
309+
284310
if self.args.action in [
285311
'apache',
286312
# TODO: But if 'mysql' was passed with '--php-myadmin',
@@ -515,6 +541,51 @@ def validate_app_args(self):
515541
return 0
516542

517543

544+
def validate_suitecrm_args(self):
545+
if self.args.action != 'suitecrm':
546+
return 0
547+
548+
if self.args.suitecrm_version == '8':
549+
self.handle_defaults([
550+
{
551+
'arg_name': 'admin_username',
552+
'cli_default_value': None,
553+
'override_default_value': DEFAULT_ADMIN_USERNAME,
554+
},
555+
], True, True)
556+
557+
if self.args.admin_password \
558+
and not self.args.insecure_cli_password:
559+
print(INSECURE_CLI_PASS_WARNING)
560+
return 1
561+
562+
if not self.args.admin_password:
563+
self.validated_args.admin_password = self.get_pass_and_check(
564+
"Please choose a password for the website's admin user: ",
565+
0,
566+
True
567+
)
568+
569+
elif self.args.suitecrm_version == '7':
570+
print(dedent("""
571+
Warning! With SuiteCRM version 7, the admin credentials must
572+
be supplied via web UI, which means anyone with web access to
573+
the host can do it.
574+
PLEASE IMMEDIATELY NAVIGATE TO YOUR WEB HOST, and complete the
575+
installation... before someone else does it for you! ;-)
576+
Also, you should use version 8 instead.
577+
"""))
578+
print(dedent("""
579+
Warning! Please be aware that SuiteCRM version 7 will not work
580+
with PHP 8.3 or newer. Also, Lampsible's '--php-version' flag
581+
is being deprecated, so you should set up your remote server
582+
with a distro that uses PHP 8.2 or older by default,
583+
like for example Ubuntu 22.
584+
"""))
585+
586+
return 0
587+
588+
518589
def validate_misc_args(self):
519590
try:
520591
self.validated_args.extra_packages = self.args.extra_packages.split(',')
@@ -584,6 +655,7 @@ def validate_args(self):
584655
'validate_joomla_args',
585656
'validate_drupal_args',
586657
'validate_app_args',
658+
'validate_suitecrm_args',
587659
'validate_misc_args',
588660
]
589661
for method_name in validate_methods:

0 commit comments

Comments
 (0)