diff --git a/plugins/devkit-pipeline-v1.1/config.yaml b/plugins/devkit-pipeline-v1.1/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..50f23264b99caa773c20a324dd4ae64c3280459f --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/config.yaml @@ -0,0 +1,47 @@ +all: + children: + controller: + hosts: + # 控制节点只能有一个,可以127.0.0.1 + 192.168.0.10: + ansible_host: 192.168.0.10 + ansible_port: 22 + ansible_user: root + ansible_password: x2openEuler_+10485760!@ + deploy_nodes: + hosts: + # 部署节点可以有任意个,允许包含控制节点,但不可以是127.0.0.1 + 192.168.0.10: + ansible_host: 192.168.0.10 + ansible_port: 22 + ansible_user: root + ansible_password: x2openEuler_+10485760!@ + vars: + pipeline: + download_url: "https://gitee.com/openeuler/devkit-pipeline/releases/download/v1.1/devkit-pipeline-v1.1.tar.gz" + install_dir: "/home/pipeline" + machine_config: + user: root + pkey: /root/.ssh/id_rsa + # 以下的节点IP必须来自deploy_nodes + # 每个项目中的IP可以有多个 + # 如果不希望安装某个项目,请将项目和对应的IP删除或注释 + scanner: + - 192.168.0.10 + c_builder_gcc: + - 192.168.0.10 + c_builder_bisheng_compiler: + - 192.168.0.10 + java_builder_jdk8: + - 192.168.0.10 + java_builder_jdk17: + - 192.168.0.10 + compatibility: + - 192.168.0.10 + tester: + - 192.168.0.10 + devkit: + - 192.168.0.10 + clamav: + - 192.168.0.10 + ansible_ssh_common_args: "-o StrictHostKeyChecking=no" \ No newline at end of file diff --git a/plugins/devkit-pipeline-v1.1/main.yaml b/plugins/devkit-pipeline-v1.1/main.yaml new file mode 100644 index 0000000000000000000000000000000000000000..69d5d8a0a6614aec48be0e289d098dc22059b705 --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/main.yaml @@ -0,0 +1,19 @@ +name: devkit-pipeline-v1.1 +version: 1.0.0-1 +description: 部署devkit-pipeline-v1.1工具链 +action: + install: + description: 安装devkit-pipeline-v1.1 + tasks: + - name: 配置SSH免密登录 + playbook: setup-ssh.yml + scope: controller + - name: 下载并解压软件包 + playbook: download-package.yml + scope: controller + - name: 生成machine-auto.yaml配置文件 + playbook: generate-config.yml + scope: controller + - name: 执行部署命令 + playbook: run-deploy.yml + scope: controller \ No newline at end of file diff --git a/plugins/devkit-pipeline-v1.1/workspace/download-package.yml b/plugins/devkit-pipeline-v1.1/workspace/download-package.yml new file mode 100644 index 0000000000000000000000000000000000000000..7f0f6b4c32688c6daf45300c5a3c951ea6031fdc --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/workspace/download-package.yml @@ -0,0 +1,30 @@ +--- +- name: Download and extract devkit-pipeline package + hosts: controller + gather_facts: false + vars: + package_name: "{{ pipeline.download_url | basename | regex_replace('\\.tar\\.gz$', '') }}" + tasks: + - name: Ensure SELinux Python bindings are installed + yum: + name: python3-libselinux + state: present + + - name: Create installation directory + ansible.builtin.file: + path: "{{ pipeline.install_dir }}" + state: directory + mode: '0755' + + - name: Download package + ansible.builtin.get_url: + url: "{{ pipeline.download_url }}" + dest: "{{ pipeline.install_dir }}/{{ package_name }}.tar.gz" + mode: '0644' + + - name: Extract package + ansible.builtin.unarchive: + src: "{{ pipeline.install_dir }}/{{ package_name }}.tar.gz" + dest: "{{ pipeline.install_dir }}" + remote_src: yes + creates: "{{ pipeline.install_dir }}/{{ package_name }}" diff --git a/plugins/devkit-pipeline-v1.1/workspace/generate-config.yml b/plugins/devkit-pipeline-v1.1/workspace/generate-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..330213aff56fb800f33d796086e892a24870c00c --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/workspace/generate-config.yml @@ -0,0 +1,18 @@ +--- +- name: Generate machine-auto.yaml configuration + hosts: controller + gather_facts: false + vars: + package_name: "{{ pipeline.download_url | basename | regex_replace('\\.tar\\.gz$', '') }}" + tasks: + - name: Create config directory + ansible.builtin.file: + path: "{{ pipeline.install_dir }}/{{ package_name }}/linux" + state: directory + mode: '0755' + + - name: Generate machine-auto.yaml + ansible.builtin.template: + src: machine-auto.j2 + dest: "{{ pipeline.install_dir }}/{{ package_name }}/linux/machine-auto.yaml" + mode: '0644' \ No newline at end of file diff --git a/plugins/devkit-pipeline-v1.1/workspace/machine-auto.j2 b/plugins/devkit-pipeline-v1.1/workspace/machine-auto.j2 new file mode 100644 index 0000000000000000000000000000000000000000..e8c349bbcf225bfff3400fb4fdbafe789eb6d710 --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/workspace/machine-auto.j2 @@ -0,0 +1,20 @@ +user: {{ pipeline.machine_config.user }} +pkey: {{ pipeline.machine_config.pkey }} +scanner: +{{ pipeline.machine_config.scanner | to_nice_yaml | indent(2) }} +c_builder_gcc: +{{ pipeline.machine_config.c_builder_gcc | to_nice_yaml | indent(2) }} +c_builder_bisheng_compiler: +{{ pipeline.machine_config.c_builder_bisheng_compiler | to_nice_yaml | indent(2) }} +java_builder_jdk8: +{{ pipeline.machine_config.java_builder_jdk8 | to_nice_yaml | indent(2) }} +java_builder_jdk17: +{{ pipeline.machine_config.java_builder_jdk17 | to_nice_yaml | indent(2) }} +compatibility: +{{ pipeline.machine_config.compatibility | to_nice_yaml | indent(2) }} +tester: +{{ pipeline.machine_config.tester | to_nice_yaml | indent(2) }} +devkit: +{{ pipeline.machine_config.devkit | to_nice_yaml | indent(2) }} +clamav: +{{ pipeline.machine_config.clamav | to_nice_yaml | indent(2) }} \ No newline at end of file diff --git a/plugins/devkit-pipeline-v1.1/workspace/run-deploy.yml b/plugins/devkit-pipeline-v1.1/workspace/run-deploy.yml new file mode 100644 index 0000000000000000000000000000000000000000..cc1f62550b3bcaaf9d3877033317d920ba3e78bc --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/workspace/run-deploy.yml @@ -0,0 +1,13 @@ +--- +- name: Run deployment command + hosts: controller + gather_facts: false + vars: + package_name: "{{ pipeline.download_url | basename | regex_replace('\\.tar\\.gz$', '') }}" + tasks: + - name: Execute deploy_tool + ansible.builtin.shell: | + cd {{ pipeline.install_dir }}/{{ package_name }}/linux + ./deploy_tool -f ./machine-auto.yaml + args: + executable: /bin/bash \ No newline at end of file diff --git a/plugins/devkit-pipeline-v1.1/workspace/setup-ssh.yml b/plugins/devkit-pipeline-v1.1/workspace/setup-ssh.yml new file mode 100644 index 0000000000000000000000000000000000000000..3e4c6dbd7d684e82c895b7d247ee6bf4c986e2f1 --- /dev/null +++ b/plugins/devkit-pipeline-v1.1/workspace/setup-ssh.yml @@ -0,0 +1,32 @@ +--- +- name: Configure SSH key-based authentication + hosts: controller + gather_facts: false + tasks: + - name: Check if SSH key exists + ansible.builtin.stat: + path: /root/.ssh/id_rsa + register: ssh_key + + - name: Generate SSH key pair if not exists + ansible.builtin.openssh_keypair: + path: /root/.ssh/id_rsa + type: rsa + size: 2048 + force: false + register: keygen_result + when: not ssh_key.stat.exists + + - name: Get public key content + ansible.builtin.shell: cat /root/.ssh/id_rsa.pub + register: public_key + when: keygen_result is changed or ssh_key.stat.exists + + - name: Distribute public key to deploy nodes + ansible.builtin.authorized_key: + user: root + key: "{{ public_key.stdout }}" + state: present + delegate_to: "{{ item }}" + loop: "{{ groups['deploy_nodes'] }}" + when: public_key is defined and public_key.stdout != "" \ No newline at end of file