-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upd(create_kci_k8s_azure_build.sh): Add token for storage #192
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
gather_facts: true | ||
become: true | ||
roles: | ||
- common | ||
- webserver |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
- name: Update apt cache | ||
apt: update_cache=yes cache_valid_time=3600 | ||
|
||
- name: Install packages | ||
apt: name={{ item }} | ||
with_items: | ||
- git | ||
- docker.io | ||
- docker-compose | ||
- python3-pip | ||
- python3-venv | ||
- curl | ||
- libssl-dev | ||
- pkg-config | ||
|
||
#- name: Add to fstab | ||
# ansible.builtin.lineinfile: | ||
# path: /etc/fstab | ||
# line: "UUID=64d72737-f1de-4f67-a22a-f693a79f228f /data ext4 defaults,nofail 0 2" | ||
# state: present | ||
|
||
- name: Mount the disk | ||
ansible.posix.mount: | ||
path=/data src=UUID=64d72737-f1de-4f67-a22a-f693a79f228f fstype=ext4 state=mounted | ||
# its ok if it fails (for simulation purposes) | ||
ignore_errors: true | ||
|
||
|
||
- name: Create data directories if they don't exist | ||
ansible.builtin.file: path={{ item.data_dir }} state=directory | ||
with_items: "{{ vhosts }}" | ||
|
||
- name: Create data directory for storage | ||
ansible.builtin.file: path=/data/storage state=directory | ||
|
||
- name: Verify if Rust installed | ||
shell: rustc --version | ||
register: rust_installed | ||
ignore_errors: true | ||
|
||
- name: Install Rust | ||
when: rust_installed.rc != 0 | ||
shell: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
args: | ||
creates: /root/rustup-init | ||
|
||
- name: Is cargo in PATH? | ||
shell: echo $PATH | grep -q "$HOME/.cargo/bin" | ||
register: cargo_in_path | ||
ignore_errors: true | ||
|
||
- name: Add cargo to PATH | ||
when: cargo_in_path.rc != 0 | ||
shell: echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> /root/.bashrc | ||
args: | ||
creates: /root/.bashrc | ||
|
||
- name: Delete old kernelci-storage directory | ||
file: path=/root/kernelci-storage state=absent | ||
ignore_errors: true | ||
|
||
- name: Clone storage repo | ||
git: | ||
repo: https://github.com/nuclearcat/kernelci-storage.git | ||
dest: /root/kernelci-storage | ||
update: true | ||
force: true | ||
|
||
- name: Build Rust program kernelci-storage | ||
shell: cd /root/kernelci-storage && cargo build --release | ||
args: | ||
creates: /root/kernelci-storage/target/release/kernelci-storage | ||
|
||
- name: Install kernelci-storage to /usr/local/bin | ||
shell: mv /root/kernelci-storage/target/release/kernelci-storage /usr/local/bin | ||
Comment on lines
+36
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest setting up kernelci-storage releases externally and just retrieving the binary to the servers. This way we limit software deployed on the server to reduce potential attacks surface and overall clutter in the systems ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's great to have |
||
|
||
- name: Create kernelci-storage config from template | ||
template: | ||
src: kernelci-storage.toml.j2 | ||
dest: /etc/kernelci-storage.toml | ||
|
||
- name: Create systemd service | ||
template: | ||
src: kernelci-storage.service.j2 | ||
dest: /etc/systemd/system/kernelci-storage.service | ||
|
||
- name: Reload systemd | ||
systemd: | ||
daemon_reload: true | ||
|
||
- name: Start and enable kernelci-storage service | ||
systemd: | ||
name: kernelci-storage | ||
enabled: true | ||
state: started |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# kernelci-storage systemd service file | ||
[Unit] | ||
Description=kernelci-storage | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/local/bin/kernelci-storage -c /etc/kernelci-storage.toml | ||
Restart=always | ||
RestartSec=5 | ||
WorkingDirectory=/data/storage | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
jwt_secret="" | ||
[azure] | ||
account="" | ||
key="" | ||
container="hotstorage" | ||
sastoken="" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- name: Reload nginx | ||
service: name=nginx state=reloaded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a volume in Azure. I think this UUID should be retrieved first with
k8s_info
task, exported as a fact and only then used here (I'll look up similar task as an example later - ping me if I forget to do so 😅)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is legacy block device i want to reuse, unfortunately this is old storage stuff i have to migrate first, but then system will be cleaned up from legacy things and recipe will change.
Main purpose of this initial recipe how to image system fast and bring up on new distro with minimum downtime (and reverse if something doesnt work).
Then, final recipe after i will finish storage cleanup will be done.