Skip to content

Commit 27d528b

Browse files
authored
Merge pull request #134 from cmckee786/ansible-feat
fix: port over changes from lac
2 parents c4cfd0a + a59bc4c commit 27d528b

File tree

2 files changed

+87
-50
lines changed

2 files changed

+87
-50
lines changed
Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,104 @@
11
---
2-
- name: Deploy local ProLUG mdBook dev page to rocky container
3-
hosts: { host }
4-
gather_facts: false
2+
- name: Deploy local ProLUG mdBook dev page machine/container
3+
hosts: # change targeted host/hosts here
54
become: true
5+
gather_facts: true
66

77
tasks:
8-
- name: Install dependencies
9-
ansible.builtin.package:
10-
update_cache: true
11-
name:
12-
- { httpd or apache2 }
13-
- git
14-
- gcc
15-
- rust
16-
- cargo
17-
state: present
8+
- name: Build ProLUG website for DNF Systems
9+
when: ansible_pkg_mgr == "dnf"
10+
block:
11+
- name: Install and initialize dependencies
12+
ansible.builtin.package:
13+
update_cache: true
14+
name:
15+
- httpd
16+
- git
17+
- gcc
18+
- rust
19+
- cargo
20+
state: present
1821

19-
- name: Enable httpd or apache2
20-
ansible.builtin.service:
21-
name: { httpd or apache2 }
22-
enabled: true
22+
- name: Initialize httpd
23+
ansible.builtin.service:
24+
name: httpd
25+
state: started
26+
enabled: true
27+
28+
- name: DNF - Installing mdbook
29+
community.general.cargo:
30+
name: mdbook
31+
locked: true
32+
state: present
33+
34+
- name: Build ProLUG website for APT systems
35+
when: ansible_pkg_mgr == "apt"
36+
block:
37+
- name: Install dependencies apt
38+
ansible.builtin.package:
39+
update_cache: true
40+
name:
41+
- apache2
42+
- git
43+
- gcc
44+
- rustc-1.80
45+
- cargo-1.80
46+
state: present
47+
48+
- name: Initialize apache2
49+
ansible.builtin.service:
50+
name: apache2
51+
state: started
52+
enabled: true
2353

24-
- name: Installing mdbook
25-
community.general.cargo:
26-
name: mdbook
27-
locked: true
28-
state: present
54+
- name: APT - Installing mdbook
55+
ansible.builtin.command:
56+
argv:
57+
- /usr/bin/cargo-1.80
58+
- install
59+
- --locked
60+
2961

3062
- name: Verifying presence of ProLUG repo
3163
ansible.builtin.command: ls /root/psc/
3264
register: contents_git
3365
ignore_errors: true
3466

35-
- name: Clone down ProLUG repo if absent
67+
- name: Cloning down ProLUG repo
3668
ansible.builtin.git:
3769
repo: "https://github.com/ProfessionalLinuxUsersGroup/psc"
3870
dest: /root/psc/
3971
clone: true
4072
when: contents_git.stdout == ""
4173

42-
- name: Verify absent httpd configuration
43-
ansible.builtin.command: ls /var/www/html/
44-
register: contents_httpd
45-
46-
- name: Checking /var/www/html not empty
47-
ansible.builtin.debug:
48-
msg: "httpd /html not empty, verify content"
49-
when: contents_httpd.stdout != ""
74+
- name: DNF - Building mdbook
75+
ansible.builtin.command:
76+
chdir: /root/psc
77+
argv:
78+
- /root/.cargo/bin/mdbook
79+
- build
80+
- --dest-dir
81+
- /var/www/html
82+
when: ansible_pkg_mgr == "dnf"
83+
notify: Restart httpd
5084

51-
- name: Builing mdbook if /html empty
85+
- name: APT - Building mdbook
5286
ansible.builtin.command:
5387
chdir: /root/psc
5488
argv:
5589
- /root/.cargo/bin/mdbook
5690
- build
5791
- --dest-dir
5892
- /var/www/html
59-
when: contents_httpd.stdout == ""
60-
notify: Restart httpd or apache2
93+
when: ansible_pkg_mgr == "apt"
94+
notify: Restart apache2
6195

6296
handlers:
63-
- name: Restart httpd or apache2
97+
- name: Restart httpd
98+
ansible.builtin.service:
99+
name: httpd
100+
state: restarted
101+
- name: Restart apache2
64102
ansible.builtin.service:
65-
name: { httpd or apache2 }
103+
name: apache2
66104
state: restarted

src/development.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ technologies as Ansible, containers, bash scripts, and more.
1717

1818
---
1919

20-
The ProLUG Security Course (PSC) utilizes [mdBook](https://github.com/rust-lang/mdBook)
20+
The ProLUG Security Course (psc) utilizes [mdBook](https://github.com/rust-lang/mdBook)
2121
(markdown Book), a friendly and popular markdown utility that quickly exports
2222
files and web structures for documentation or general website use cases.
2323

@@ -32,7 +32,7 @@ Below is the current workflow that deploys the Git Page for the course:
3232

3333
</div>
3434

35-
To achieve this workflow locally the following environment and dependencies are
35+
To achieve this deployment locally the following environment and dependencies are
3636
required:
3737

3838
<dl>
@@ -60,12 +60,11 @@ environments if things go awry.
6060
<https://github.com/ProfessionalLinuxUsersGroup/psc/blob/main/src/assets/deploy/ansible-playbook.yml>
6161

6262
To use this playbook, your machine(s)/containers must be configured correctly for Ansible.
63-
If you don't know the requirements to administer a machine via Ansible, documentation
63+
If you don't know the requirements to administer a machine via Ansible documentation
6464
has been provided below.
6565

6666
<div class = warning>
67-
This playbook will need to be modified based on which distribution or package management
68-
tool is configured.
67+
This playbook attempts to install and initialize dependencies based on APT and DNF package managers only.
6968
</div>
7069

7170
Getting started with Ansible:
@@ -95,29 +94,29 @@ Tested with Rocky 9 and Ubuntu 24.04 Containers.
9594
APT frontends:
9695

9796
```bash
98-
#!/bin/bash
97+
#!/usr/bin/env bash
9998
apt-get update
10099
apt-get -y install apache2 git gcc rustc-1.80 cargo-1.80
101-
cargo-1.80 install --locked mdbook
102-
systemctl enable apache2 && systemctl start apache2
100+
cargo-1.80 install --locked mdbook@0.4.48
101+
systemctl enable --now apache2
103102
cd && git clone https://github.com/ProfessionalLinuxUsersGroup/psc
104103
echo 'PATH=$PATH:~/.cargo/bin/' | tee -a ~/.profile
105-
export PATH=$PATH:~/.cargo/bin/ && echo $PATH
104+
export PATH=$PATH:~/.cargo/bin/ && echo $PATH | grep cargo
106105
cd ~/psc && mdbook build -d /var/www/html
107106
systemctl restart apache2
108107
```
109108

110109
DNF frontends:
111110

112111
```bash
113-
#!/bin/bash
112+
#!/usr/bin/env bash
114113
dnf update
115114
dnf install -y httpd git gcc rust cargo
116115
cargo install --locked mdbook
117-
systemctl enable httpd && systemctl start httpd
116+
systemctl enable --now httpd
118117
cd && git clone https://github.com/ProfessionalLinuxUsersGroup/psc
119118
echo 'PATH=$PATH:~/.cargo/bin/' | tee -a ~/.bash_profile
120-
export PATH=$PATH:~/.cargo/bin/ && echo $PATH
119+
export PATH=$PATH:~/.cargo/bin/ && echo $PATH | grep cargo
121120
cd ~/psc && mdbook build -d /var/www/html
122121
systemctl restart httpd
123122
```
@@ -138,8 +137,8 @@ From there you should be able to see any changes you have made are reflected.
138137

139138
#### Or send commands over to a networked container or machine:
140139

141-
**Note:** To minimize complexity and given the nature of commands over SSH, these
142-
commands will need to utilize absolute paths.
140+
**Note:** To minimize complexity and given the nature of commands over SSH,
141+
these commands will need to utilize absolute paths.
143142

144143
```bash
145144
scp {working directory}/{targeted document} {TARGET_IP}:/root/psc/src/{targeted document}

0 commit comments

Comments
 (0)