Skip to content

Commit

Permalink
Update jenkins envs for classic and ansible modes
Browse files Browse the repository at this point in the history
  • Loading branch information
exitfound committed Mar 31, 2024
1 parent 6097a37 commit 42bc758
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 82 deletions.
13 changes: 11 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ JCASC_JENKINS_AGENT_2_IP="192.168.1.11"

JCASC_JENKINS_ADMIN_USER="admin"
JCASC_JENKINS_ADMIN_PASSWORD="Kitezh1165"
JCASC_JENKINS_ADMIN_EMAIL="[email protected]"
JCASC_JENKINS_ADMIN_EMAIL="[email protected]"

# Переменные, используемые в секции Security, для последующей конфигурации JCasC:

Expand All @@ -42,8 +42,17 @@ JCASC_TOOL_GO_VERSION="1.21.7"
# Переменные, используемые в секции Unclassified, для последующей конфигурации JCasC:

JCASC_UNCLASSIFIED_URL="http://localhost:8080"
JCASC_UNCLASSIFIED_EMAIL="[email protected]"
JCASC_UNCLASSIFIED_EMAIL="[email protected]"
JCASC_UNCLASSIFIED_LOCALE="en_US"

JCASC_UNCLASSIFIED_SL_NAME="MySharedLibraries"
JCASC_UNCLASSIFIED_SL_URL="https://github.com/exitfound/docker-autossh.git"
JCASC_UNCLASSIFIED_SL_SSH="MySshCredentialId"

JCASC_UNCLASSIFIED_GITLAB_NAME="MyGitlabConnection"
JCASC_UNCLASSIFIED_GITLAB_URL="https://gitlab.com"

JCASC_UNCLASSIFIED_GITHUB_NAME="MyGithubConnection"
JCASC_UNCLASSIFIED_GITHUB_URL="https://api.github.com"

JCASC_UNCLASSIFIED_SLACK_WORKSPACE="onlyyourworkspace"
32 changes: 18 additions & 14 deletions ansible/group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,29 @@ manual_jenkins_agent_public_key: "ssh-rsa yourpublickey"

# Переменные, используемые в секции Credentials, для последующей конфигурации JCasC:

jcasc_credential_ssh_id: "MySshCredentialId"
jcasc_credential_ssh_username: "builder"
jcasc_credential_ssh_private_key: "MySshPrivateKey"
jcasc_credential_ssh_passphrase: "MySshPassphrase"
jcasc_credential_ssh_id_one: "MySshCredentialId"
jcasc_credential_ssh_username_one: "builder"
jcasc_credential_ssh_private_key_one: "MySshPrivateKey"
jcasc_credential_ssh_passphrase_one: "MySshPassphrase"

jcasc_credential_gitlab_id: "MyGitlabId"
jcasc_credential_gitlab_token: "MyGitlabToken"
jcasc_credential_gitlab_id_one: "MyGitlabId"
jcasc_credential_gitlab_token_one: "MyGitlabToken"

jcasc_credential_github_id: "MyGithubId"
jcasc_credential_github_token: "MyGithubToken"
jcasc_credential_github_id_one: "MyGithubId"
jcasc_credential_github_token_one: "MyGithubToken"

# Переменные, используемые в секции Jenkins, для последующей конфигурации JCasC:
jcasc_credential_slack_id_one_one: "MySlackTokenId"
jcasc_credential_slack_token_one_one: "MySlackToken"

jcasc_jenkins_remote_fs: "/var/lib/jenkins"
# Переменные, используемые в секции Jenkins, для последующей конфигурации JCasC:

jcasc_jenkins_agent_1_name: "agent-1"
jcasc_jenkins_agent_1_label: "agent-1"
jcasc_jenkins_agent_1_ip: "192.168.88.218"
jcasc_jenkins_agent_1_ip: "192.168.1.10"

jcasc_jenkins_agent_2_name: "agent-2"
jcasc_jenkins_agent_2_label: "agent-2"
jcasc_jenkins_agent_2_ip: "192.168.88.219"
jcasc_jenkins_agent_2_ip: "192.168.1.11"

jcasc_jenkins_admin_user: "admin"
jcasc_jenkins_admin_password: "Kitezh1165"
Expand All @@ -54,11 +55,14 @@ jcasc_jenkins_admin_email: "[email protected]"

# Переменные, используемые в секции Tool, для последующей конфигурации jcasc:

jcasc_tool_maven_version: "3.9.0"
jcasc_tool_jdk_version: "jdk-11.0.14+9"
jcasc_tool_maven_version: "3.9.6"
jcasc_tool_jdk_version: "jdk-21.0.2+13"
jcasc_tool_nodejs_version: "20.11.0"
jcasc_tool_go_version: "1.21.7"

# Переменные, используемые в секции Unclassified, для последующей конфигурации jcasc:

jcasc_unclassified_url: "http://localhost:8080"
jcasc_unclassified_email: "[email protected]"
jcasc_unclassified_locale: "en_US"

Expand Down
14 changes: 13 additions & 1 deletion ansible/hosts/servers
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[all:vars]

[suse:children]
opensuse15.4
opensuse15.3
opensuse15.4
opensuse15.5

[redhat:children]
centos8
Expand All @@ -11,15 +12,20 @@ centos9
[debian:children]
ubuntu20.04
ubuntu22.04
ubuntu24.04
debian10
debian11
debian12

[opensuse15.3]
opensuse15.3-instance1 ansible_host=suse153.kitezh.online jenkins_nginx_domain=suse153.kitezh.online

[opensuse15.4]
opensuse15.4-instance1 ansible_host=suse154.kitezh.online jenkins_nginx_domain=suse154.kitezh.online

[opensuse15.5]
opensuse15.5-instance1 ansible_host=suse155.kitezh.online jenkins_nginx_domain=suse155.kitezh.online

[centos8]
centos8-instance1 ansible_host=centos9.kitezh.online jenkins_nginx_domain=centos9.kitezh.online

Expand All @@ -32,8 +38,14 @@ ubuntu20.04-instance1 ansible_host=ubu20.kitezh.online jenkins_nginx_domai
[ubuntu22.04]
ubuntu22.04-instance1 ansible_host=ubu22.kitezh.online jenkins_nginx_domain=ubu22.kitezh.online

[ubuntu24.04]
ubuntu24.04-instance1 ansible_host=ubu24.kitezh.online jenkins_nginx_domain=ubu24.kitezh.online

[debian10]
debian10-instance1 ansible_host=debian10.kitezh.online jenkins_nginx_domain=debian10.kitezh.online

[debian11]
debian11-instance1 ansible_host=debian11.kitezh.online jenkins_nginx_domain=debian11.kitezh.online

[debian12]
debian12-instance1 ansible_host=debian12.kitezh.online jenkins_nginx_domain=debian12.kitezh.online
3 changes: 1 addition & 2 deletions ansible/roles/docker-jenkins/files/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ RUN mkdir -p /var/jenkins_config/casc_configs/ /var/jenkins_backup \
iproute2 \
&& apt-get clean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
&& rm -rf /tmp/* /var/tmp/*
&& rm -rf /var/lib/apt /var/lib/dpkg /tmp/* /var/tmp/*

USER jenkins

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
context: .
dockerfile: Dockerfile
container_name: jenkins-master
image: jenkins-master
user: jenkins
ports:
- 0.0.0.0:8080:8080
Expand Down
4 changes: 4 additions & 0 deletions ansible/roles/docker-jenkins/files/plugins.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ credentials
credentials-binding
commons-text-api
display-url-api
docker-java-api
docker-plugin
email-ext
git
github
github-api
github-branch-source
gitlab-plugin
golang
gradle
jaxb
jackson2-api
Expand All @@ -34,6 +36,7 @@ locale
mailer
matrix-auth
matrix-project
nodejs
pam-auth
okhttp-api
periodicbackup
Expand All @@ -52,6 +55,7 @@ pipeline-stage-view
role-strategy
script-security
scm-api
slack
ssh-agent
ssh-credentials
ssh-slaves
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ platforms:
security_opts:
- seccomp=unconfined


# - name: ubuntu24.04
# image: mdd13/ansible-docker-ubuntu:ubuntu24.04
# pre_build_image: true
Expand Down
36 changes: 20 additions & 16 deletions ansible/roles/docker-jenkins/molecule/group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,49 @@ jenkins_nginx_domain: "mylocal.domain"

# Переменные, используемые в секции Credentials, для последующей конфигурации JCasC:

jcasc_credential_ssh_id: "MySshCredentialId"
jcasc_credential_ssh_username: "builder"
jcasc_credential_ssh_private_key: "MySshPrivateKey"
jcasc_credential_ssh_passphrase: "MySshPassphrase"
jcasc_credential_ssh_id_one: "MySshCredentialId"
jcasc_credential_ssh_username_one: "builder"
jcasc_credential_ssh_private_key_one: "MySshPrivateKey"
jcasc_credential_ssh_passphrase_one: "MySshPassphrase"

jcasc_credential_gitlab_id: "MyGitlabId"
jcasc_credential_gitlab_token: "MyGitlabToken"
jcasc_credential_gitlab_id_one: "MyGitlabId"
jcasc_credential_gitlab_token_one: "MyGitlabToken"

jcasc_credential_github_id: "MyGithubId"
jcasc_credential_github_token: "MyGithubToken"
jcasc_credential_github_id_one: "MyGithubId"
jcasc_credential_github_token_one: "MyGithubToken"

# Переменные, используемые в секции Jenkins, для последующей конфигурации JCasC:
jcasc_credential_slack_id_one_one: "MySlackTokenId"
jcasc_credential_slack_token_one_one: "MySlackToken"

jcasc_jenkins_remote_fs: "/var/lib/jenkins"
# Переменные, используемые в секции Jenkins, для последующей конфигурации JCasC:

jcasc_jenkins_agent_1_name: "agent-1"
jcasc_jenkins_agent_1_label: "agent-1"
jcasc_jenkins_agent_1_ip: "192.168.88.218"
jcasc_jenkins_agent_1_ip: "192.168.1.10"

jcasc_jenkins_agent_2_name: "agent-2"
jcasc_jenkins_agent_2_label: "agent-2"
jcasc_jenkins_agent_2_ip: "192.168.88.219"
jcasc_jenkins_agent_2_ip: "192.168.1.11"

jcasc_jenkins_admin_user: "admin"
jcasc_jenkins_admin_password: "Kitezh1165"
jcasc_jenkins_admin_email: "[email protected]"
jcasc_jenkins_admin_email: "[email protected]"

# Переменные, используемые в секции Security, для последующей конфигурации jcasc:

# -

# Переменные, используемые в секции Tool, для последующей конфигурации jcasc:

jcasc_tool_maven_version: "3.9.0"
jcasc_tool_jdk_version: "jdk-11.0.14+9"
jcasc_tool_maven_version: "3.9.6"
jcasc_tool_jdk_version: "jdk-21.0.2+13"
jcasc_tool_nodejs_version: "20.11.0"
jcasc_tool_go_version: "1.21.7"

# Переменные, используемые в секции Unclassified, для последующей конфигурации jcasc:

jcasc_unclassified_email: "[email protected]"
jcasc_unclassified_url: "http://localhost:8080"
jcasc_unclassified_email: "[email protected]"
jcasc_unclassified_locale: "en_US"

jcasc_unclassified_gitlab_name: "MyGitlabConnection"
Expand Down
27 changes: 17 additions & 10 deletions ansible/roles/docker-jenkins/templates/credentials.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,32 @@ credentials:
- credentials:
# Создание учетной записи для использования приватного SSH ключа:
- basicSSHUserPrivateKey:
scope: SYSTEM
id: {{ jcasc_credential_ssh_id }}
username: {{ jcasc_credential_ssh_username }}
scope: GLOBAL
id: {{ jcasc_credential_ssh_id_one }}
username: {{ jcasc_credential_ssh_username_one }}
description: "This your private SSH key for deploy"
privateKeySource:
directEntry:
privateKey: {{ jcasc_credential_ssh_private_key }}
# passphrase: {{ jcasc_credential_ssh_passphrase }}
privateKey: {{ jcasc_credential_ssh_private_key_one }}
# passphrase: {{ jcasc_credential_ssh_passphrase_one }}

# Создание учетной записи для использования токена Gitlab:
- gitLabApiTokenImpl:
scope: SYSTEM
id: {{ jcasc_credential_gitlab_id }}
apiToken: {{ jcasc_credential_gitlab_token }}
scope: GLOBAL
id: {{ jcasc_credential_gitlab_id_one }}
apiToken: {{ jcasc_credential_gitlab_token_one }}
description: "My Gitlab Token"

# Создание учетной записи для использования токена Github:
- string:
scope: GLOBAL
id: {{ jcasc_credential_github_id }}
secret: {{ jcasc_credential_github_token }}
id: {{ jcasc_credential_github_id_one }}
secret: {{ jcasc_credential_github_token_one }}
description: "My Github Token"

# Создание учетной записи для использования токена Slack:
- string:
scope: GLOBAL
id: "${JCASC_CREDENTIAL_SLACK_ID_ONE}"
secret: "${JCASC_CREDENTIAL_SLACK_TOKEN_ONE}"
description: "My Slack Token"
Loading

0 comments on commit 42bc758

Please sign in to comment.