conf(dev): add workspace file, setup script and requirements files
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,7 +13,6 @@ test.yml
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
27
ansible-common.code-workspace
Normal file
27
ansible-common.code-workspace
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"files.associations": {
|
||||
"*.yml": "ansible",
|
||||
"*.j2": "ansible-jinja"
|
||||
},
|
||||
"ansible.python.interpreterPath": "${workspaceFolder}/.venv/bin/python",
|
||||
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
|
||||
"editor.tabSize": 2,
|
||||
"trailing-spaces.highlightCurrentLine": false,
|
||||
"trailing-spaces.schemeIgnore": [
|
||||
"markdown",
|
||||
"output"
|
||||
]
|
||||
},
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"redhat.ansible",
|
||||
"shardulm94.trailing-spaces"
|
||||
]
|
||||
}
|
||||
}
|
||||
30
requirements-freeze.txt
Normal file
30
requirements-freeze.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
ansible==11.1.0
|
||||
ansible-compat==24.10.0
|
||||
ansible-core==2.18.1
|
||||
ansible-lint==24.12.2
|
||||
attrs==24.3.0
|
||||
black==24.10.0
|
||||
bracex==2.5.post1
|
||||
cffi==1.17.1
|
||||
click==8.1.8
|
||||
cryptography==44.0.0
|
||||
filelock==3.16.1
|
||||
importlib_metadata==8.5.0
|
||||
Jinja2==3.1.5
|
||||
jsonschema==4.23.0
|
||||
jsonschema-specifications==2024.10.1
|
||||
MarkupSafe==3.0.2
|
||||
mypy-extensions==1.0.0
|
||||
packaging==24.2
|
||||
pathspec==0.12.1
|
||||
platformdirs==4.3.6
|
||||
pycparser==2.22
|
||||
PyYAML==6.0.2
|
||||
referencing==0.35.1
|
||||
resolvelib==1.0.1
|
||||
rpds-py==0.22.3
|
||||
ruamel.yaml==0.18.6
|
||||
subprocess-tee==0.4.2
|
||||
wcmatch==10.0
|
||||
yamllint==1.35.1
|
||||
zipp==3.21.0
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
ansible
|
||||
ansible-lint
|
||||
74
setup.sh
Executable file
74
setup.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
# exit immediately if a command exits with a non-zero status
|
||||
set -e
|
||||
|
||||
VENV_DIR=.venv
|
||||
|
||||
# define color codes for output
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
YELLOW=$(tput setaf 3)
|
||||
BLUE=$(tput setaf 4; tput bold)
|
||||
NC=$(tput sgr0) # no color
|
||||
|
||||
# function to check for required commands
|
||||
check_command() {
|
||||
command -v "$1" >/dev/null 2>&1 || {
|
||||
echo -e "${RED}error: $1 is not installed. please install it and try again.${NC}" >&2;
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
# function to install the latest python
|
||||
install_python() {
|
||||
echo -e "${BLUE}installing the latest python...${NC}"
|
||||
sudo pacman -S python --noconfirm
|
||||
}
|
||||
|
||||
# function to create a virtual environment
|
||||
create_virtualenv() {
|
||||
check_command "python"
|
||||
echo -e "${BLUE}creating virtual environment...${NC}"
|
||||
if [ ! -d "$VENV_DIR" ]; then
|
||||
python -m venv $VENV_DIR
|
||||
echo -e "${GREEN}virtual environment created at $VENV_DIR${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}virtual environment already exists at $VENV_DIR${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# function to install python requirements
|
||||
install_requirements() {
|
||||
check_command "pip"
|
||||
echo -e "${BLUE}installing python requirements from requirements-freeze.txt...${NC}"
|
||||
source $VENV_DIR/bin/activate
|
||||
pip install --upgrade pip
|
||||
if [ -f "requirements-freeze.txt" ]; then
|
||||
pip install -r requirements-freeze.txt
|
||||
else
|
||||
echo -e "${YELLOW}requirements-freeze.txt not found. skipping python requirements installation.${NC}"
|
||||
fi
|
||||
deactivate
|
||||
}
|
||||
|
||||
# function to install ansible roles from requirements.yml
|
||||
install_ansible_requirements() {
|
||||
check_command "ansible-galaxy"
|
||||
echo -e "${BLUE}installing ansible roles from requirements.yml...${NC}"
|
||||
if [ -f "requirements.yml" ]; then
|
||||
source $VENV_DIR/bin/activate
|
||||
ansible-galaxy install -r requirements.yml
|
||||
deactivate
|
||||
else
|
||||
echo -e "${YELLOW}requirements.yml not found. skipping ansible requirements installation.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# main script execution
|
||||
install_python # install the latest python
|
||||
create_virtualenv # create a virtual environment
|
||||
install_requirements # install python requirements
|
||||
install_ansible_requirements # install ansible requirements
|
||||
|
||||
echo -e "${GREEN}setup completed successfully!${NC}"
|
||||
Reference in New Issue
Block a user