Skip to content

Commit 6fe32c9

Browse files
miniconda-22-04
1 parent 874abca commit 6fe32c9

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
RED='\033[1;31m'
4+
NC='\033[0m'
5+
6+
echo -e "${RED}
7+
################################################################################################################
8+
# Your MarketPlace App has been deployed successfully! #
9+
# Passwords are stored under /root/ #
10+
################################################################################################################
11+
${NC}"
12+
13+
echo
14+
echo -e "${RED}This message will be removed in the next login!${NC}"
15+
echo
16+
echo -e "${RED}Miniconda files are stored under /home/mconda/miniconda/${NC}"
17+
echo
18+
echo
19+
echo -e "${RED}Refer to the below Miniconda shell login credentials${NC}"
20+
echo
21+
cat /root/.shell_user_passwords
22+
echo
23+
24+
#Cleanup script
25+
rm -rf /usr/local/src/
26+
mkdir -p /usr/local/src/
27+
rm -rf /var/lib/cloud/instances/*
28+
rm -rf /var/lib/cloud/data/*
29+
find /var/log -mtime -1 -type f -exec truncate -s 0 {} \; >/dev/null 2>&1
30+
rm -rf /var/log/*.gz /var/log/*.[0-9] /var/log/*-????????
31+
cat /dev/null > /var/log/lastlog; cat /dev/null > /var/log/wtmp
32+
apt-get -y autoremove >/dev/null 2>&1
33+
apt-get -y autoclean >/dev/null 2>&1
34+
history -c
35+
cat /dev/null > /root/.bash_history
36+
unset HISTFILE
37+
38+
rm -rf /root/.bashrc
39+
cp /etc/skel/.bashrc /root

miniconda-22-04/miniconda.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
mkdir -p {/usr/local/src/miniconda-22-04/opt/cloudstack/,/usr/local/src/miniconda-22-04/}
4+
5+
cd /usr/local/src/miniconda-22-04/opt/cloudstack/ && wget https://raw.githubusercontent.com/stackbill/marketplace/main/_common-files/opt/cloudstack/miniconda-cleanup.sh
6+
7+
cd /usr/local/src/miniconda-22-04/ && wget https://raw.githubusercontent.com/stackbill/marketplace/main/miniconda-22-04/miniconda.yaml

miniconda-22-04/miniconda.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
- name: Miniconda Setup
2+
hosts: localhost
3+
tasks:
4+
- name: Restarting sshd
5+
shell: "sed -i 's/#Match User anoncvs/ForceCommand echo Please wait until the installation is completed..../g' /etc/ssh/sshd_config && systemctl restart sshd"
6+
7+
- name: Updating Packages
8+
ansible.builtin.apt:
9+
update_cache: yes
10+
11+
- name: Generating shell user password
12+
shell: openssl rand -hex 24
13+
register: userpassword
14+
15+
- debug:
16+
var: userpassword.stdout
17+
18+
- name: Storing shell user password
19+
copy:
20+
dest: "/root/.shell_user_passwords"
21+
content: |
22+
MINICONDA_SHELL_LOGIN_USER = mconda
23+
MINICONDA_SHELL_LOGIN_USER_PASSWORD = "{{ userpassword.stdout }}"
24+
25+
- name: Creating a user for Miniconda project
26+
ansible.builtin.user:
27+
name: mconda
28+
shell: /bin/bash
29+
create_home: yes
30+
home: "/home/mconda"
31+
32+
- name: Setting password for the user
33+
shell: echo "mconda:"{{ userpassword.stdout }}"" | chpasswd -
34+
35+
- name: Downloading Miniconda shell file
36+
uri:
37+
url: 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh'
38+
method: GET
39+
dest: /usr/local/src/
40+
41+
- name: Installing Miniconda
42+
shell: "{{ item }}"
43+
with_items:
44+
- sha256sum /usr/local/src/Miniconda3-latest-Linux-x86_64.sh
45+
- chmod +x /usr/local/src/Miniconda3-latest-Linux-x86_64.sh
46+
- runuser -l mconda -c "( echo ; echo yes ; echo /home/mconda/miniconda ; echo yes ) | bash /usr/local/src/Miniconda3-latest-Linux-x86_64.sh"
47+
48+
- name: Creating a directory for shell script
49+
ansible.builtin.file:
50+
path: /opt/cloudstack
51+
state: directory
52+
53+
- name: Copy files for shell script
54+
copy:
55+
src: "{{ item.confsrc }}"
56+
dest: "{{ item.confdest }}"
57+
with_items:
58+
- { confsrc: '/usr/local/src/miniconda-22-04/opt/cloudstack/miniconda-cleanup.sh', confdest: '/opt/cloudstack/'}
59+
60+
- name: Adding a line for shell script
61+
lineinfile:
62+
path: /root/.bashrc
63+
line: "chmod +x /opt/cloudstack/miniconda-cleanup.sh && /opt/cloudstack/miniconda-cleanup.sh"
64+
state: present
65+
66+
- name: Restarting sshd
67+
shell: "sed -i 's/ForceCommand echo Please wait until the installation is completed..../#Match User anoncvs/g' /etc/ssh/sshd_config && systemctl restart sshd"

0 commit comments

Comments
 (0)