-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from abolfazl8131/jcasc
add Jcasc
- Loading branch information
Showing
22 changed files
with
634 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,160 @@ | ||
Hello! How can I assist you today? | ||
import os | ||
|
||
project_name = "app/media/MyAnsible" | ||
roles_dir = os.path.join(project_name, "roles") | ||
nginx_dir = os.path.join(roles_dir, "nginx") | ||
tasks_dir = os.path.join(nginx_dir, "tasks") | ||
handlers_dir = os.path.join(nginx_dir, "handlers") | ||
var_dir = os.path.join(nginx_dir, "var") | ||
meta_dir = os.path.join(nginx_dir, "meta") | ||
|
||
# Create project directories | ||
os.makedirs(nginx_dir, exist_ok=True) | ||
os.makedirs(tasks_dir, exist_ok=True) | ||
os.makedirs(handlers_dir, exist_ok=True) | ||
os.makedirs(var_dir, exist_ok=True) | ||
os.makedirs(meta_dir, exist_ok=True) | ||
|
||
# Create install_nginx.yaml | ||
with open(os.path.join(project_name, "install_nginx.yaml"), "w") as main_file: | ||
main_file.write('''--- | ||
- name: install nginx service | ||
hosts: | ||
- dest | ||
roles: | ||
- nginx | ||
''') | ||
|
||
# Create handlers/main.yaml | ||
with open(os.path.join(handlers_dir, "main.yaml"), "w") as handlers_file: | ||
handlers_file.write('''--- | ||
- name: restart nginx | ||
service: | ||
name: "{ service }" | ||
state: restarted | ||
- name: restart firewall | ||
service: | ||
name: firewalld | ||
state: restarted | ||
''') | ||
|
||
# Create tasks/main.yaml | ||
with open(os.path.join(tasks_dir, "main.yaml"), "w") as tasks_file: | ||
tasks_file.write('''--- | ||
# tasks file for nginx | ||
- name: download page | ||
include: download_webpage.yml | ||
- name: unzip | ||
include: unzip.yml | ||
- name: install service | ||
include: install_service.yml | ||
- name: open website port https | ||
firewalld: | ||
service: https | ||
permanent: yes | ||
state: enabled | ||
notify: | ||
- restart firewall | ||
- name: open website port http | ||
firewalld: | ||
zone: public | ||
service: http | ||
permanent: yes | ||
state: enabled | ||
notify: | ||
- restart firewall | ||
- name: webpage | ||
include: copy_files.yml | ||
''') | ||
|
||
# Create tasks/unzip.yaml | ||
with open(os.path.join(tasks_dir, "unzip.yaml"), "w") as unzip_file: | ||
unzip_file.write('''--- | ||
- name: unarchive zip file | ||
ansible.builtin.unarchive: | ||
src: /home/ansible/ninom.zip | ||
dest: /home/ansible | ||
remote_src: yes | ||
register: unzip | ||
- debug: | ||
var: unzip | ||
''') | ||
|
||
# Create tasks/download_webpage.yaml | ||
with open(os.path.join(tasks_dir, "download_webpage.yaml"), "w") as download_file: | ||
download_file.write('''--- | ||
- name: download webpage | ||
ansible.builtin.get_url: | ||
url: "{ url_path }" | ||
dest: /home/ansible | ||
timeout: 20 | ||
validate_certs: no | ||
register: download | ||
ignore_errors: True | ||
- debug: | ||
var: download | ||
''') | ||
|
||
# Create tasks/install_service.yaml | ||
with open(os.path.join(tasks_dir, "install_service.yaml"), "w") as install_file: | ||
install_file.write('''--- | ||
- name: install { service } | ||
register: install | ||
ansible.builtin.package: | ||
name: "{ item }" | ||
state: latest | ||
loop: | ||
- "{ service }" | ||
- debug: | ||
var: install | ||
''') | ||
|
||
# Create tasks/copy_files.yaml | ||
with open(os.path.join(tasks_dir, "copy_files.yaml"), "w") as copy_file: | ||
copy_file.write('''--- | ||
- name: delete before context | ||
shell: "rm -rf /usr/share/nginx/html/*" | ||
register: delete | ||
- debug: | ||
var: delete | ||
- name: copy html file on the html main dir | ||
register: copy_file | ||
copy: | ||
src: /home/ansible/ninom-html/ | ||
dest: /usr/share/nginx/html/ | ||
remote_src: yes | ||
directory_mode: yes | ||
notify: | ||
- restart nginx | ||
- debug: | ||
var: copy_file | ||
''') | ||
|
||
# Create var/main.yaml | ||
with open(os.path.join(var_dir, "main.yaml"), "w") as var_file: | ||
var_file.write('''--- | ||
# vars file for nginx | ||
#url_path : https://www.free-css.com/assets/files/free-css-templates/download/page261/avalon.zip | ||
url_path : https://www.free-css.com/assets/files/free-css-templates/download/page283/ninom.zip | ||
service: nginx | ||
''') | ||
|
||
# Create meta/main.yaml | ||
with open(os.path.join(meta_dir, "main.yaml"), "w") as meta_file: | ||
meta_file.write('''--- | ||
allow_duplicates: yes | ||
dependencies: | ||
- { role: pre-install } | ||
''') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from app.routes.utils import * | ||
from app.routes.terraform import * | ||
from app.routes.helm import * | ||
from app.routes.ansible import * | ||
from app.routes.ansible import * | ||
from app.routes.jcasc import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: install nginx service | ||
hosts: | ||
- dest | ||
roles: | ||
- nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: restart nginx | ||
service: | ||
name: "{ service }" | ||
state: restarted | ||
|
||
- name: restart firewall | ||
service: | ||
name: firewalld | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
allow_duplicates: yes | ||
dependencies: | ||
- { role: pre-install } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: delete before context | ||
shell: "rm -rf /usr/share/nginx/html/*" | ||
register: delete | ||
|
||
- debug: | ||
var: delete | ||
|
||
- name: copy html file on the html main dir | ||
register: copy_file | ||
copy: | ||
src: /home/ansible/ninom-html/ | ||
dest: /usr/share/nginx/html/ | ||
remote_src: yes | ||
directory_mode: yes | ||
notify: | ||
- restart nginx | ||
|
||
- debug: | ||
var: copy_file |
12 changes: 12 additions & 0 deletions
12
app/media/MyAnsible/roles/nginx/tasks/download_webpage.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: download webpage | ||
ansible.builtin.get_url: | ||
url: "{ url_path }" | ||
dest: /home/ansible | ||
timeout: 20 | ||
validate_certs: no | ||
register: download | ||
ignore_errors: True | ||
|
||
- debug: | ||
var: download |
11 changes: 11 additions & 0 deletions
11
app/media/MyAnsible/roles/nginx/tasks/install_service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: install { service } | ||
register: install | ||
ansible.builtin.package: | ||
name: "{ item }" | ||
state: latest | ||
loop: | ||
- "{ service }" | ||
|
||
- debug: | ||
var: install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
# tasks file for nginx | ||
- name: download page | ||
include: download_webpage.yml | ||
|
||
- name: unzip | ||
include: unzip.yml | ||
|
||
- name: install service | ||
include: install_service.yml | ||
|
||
- name: open website port https | ||
firewalld: | ||
service: https | ||
permanent: yes | ||
state: enabled | ||
notify: | ||
- restart firewall | ||
|
||
- name: open website port http | ||
firewalld: | ||
zone: public | ||
service: http | ||
permanent: yes | ||
state: enabled | ||
notify: | ||
- restart firewall | ||
|
||
- name: webpage | ||
include: copy_files.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: unarchive zip file | ||
ansible.builtin.unarchive: | ||
src: /home/ansible/ninom.zip | ||
dest: /home/ansible | ||
remote_src: yes | ||
register: unzip | ||
|
||
- debug: | ||
var: unzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# vars file for nginx | ||
#url_path : https://www.free-css.com/assets/files/free-css-templates/download/page261/avalon.zip | ||
url_path : https://www.free-css.com/assets/files/free-css-templates/download/page283/ninom.zip | ||
service: nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{/* | ||
Common template helpers | ||
*/}} | ||
{{- define "my-helm.fullname" -}} | ||
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: web-ingress | ||
spec: | ||
rules: | ||
- host: 123.com | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: web | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
resource "argocd_repository" "repository" { | ||
count = var.repository_create ? 1 : 0 | ||
repo = var.argocd_repository_info["repo"] | ||
username = var.argocd_repository_info["username"] | ||
password = var.argocd_repository_info["password"] | ||
} | ||
|
||
resource "argocd_application" "application" { | ||
count = var.application_create ? 1 : 0 | ||
|
||
depends_on = [] | ||
|
||
metadata { | ||
name = var.argocd_application["name"] | ||
namespace = "argocd" | ||
labels = { | ||
using_sync_policy_options = "true" | ||
} | ||
} | ||
|
||
spec { | ||
destination { | ||
server = var.argocd_application["destination_server"] | ||
namespace = var.argocd_application["destination_namespace"] | ||
} | ||
|
||
source { | ||
repo_url = var.argocd_application["source_repo_url"] | ||
path = var.argocd_application["source_path"] | ||
target_revision = var.argocd_application["source_target_revision"] | ||
} | ||
|
||
sync_policy { | ||
automated { | ||
prune = false | ||
self_heal = true | ||
} | ||
sync_options = var.argocd_sync_options | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
repository_create = false | ||
argocd_repository_info = { | ||
repo = "https://YOUR_REPO.git" | ||
username = "USERNAME" | ||
password = "CHANGE_ME_WITH_TOKEN" | ||
} | ||
|
||
application_create = true | ||
argocd_application = { | ||
name = "APPLICATION_NAME" | ||
destination_server = "https://kubernetes.default.svc" | ||
destination_namespace = "DESTINATION_NAMESPACE" | ||
source_repo_url = "https://YOUR_REPO.git" | ||
source_path = "SOURCE_PATH" | ||
source_target_revision = "SOURCE_TARGET_REVISION" | ||
} | ||
|
||
argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
variable "repository_create" { | ||
type = bool | ||
} | ||
|
||
variable "argocd_repository_info" { | ||
type = map(string) | ||
} | ||
|
||
variable "application_create" { | ||
type = bool | ||
} | ||
|
||
variable "argocd_application" { | ||
type = map(string) | ||
} | ||
|
||
variable "argocd_sync_options" { | ||
type = list(string) | ||
} |
Oops, something went wrong.