diff --git a/.ansibledoctor.yml b/.ansibledoctor.yml new file mode 100644 index 0000000000000000000000000000000000000000..5b8c7036114e398612ec3d9686e898d9c493ffce --- /dev/null +++ b/.ansibledoctor.yml @@ -0,0 +1,33 @@ +--- +role: + name: "deployer" + autodetect: True + +# Don't write anything to file system. +dry_run: False + +exclude_files: [] +# Examples +# exclude_files: +# - molecule/ +# - files/**/*.py + +# Exclude tags from automatic detection. Configured tags are only skipped +# if the tag is not used in an annotation. +exclude_tags: [] + +logging: + # Possible options: debug|info|warning| error|critical + level: "warning" + # JSON logging can be enabled if a parsable output is required. + json: False + +template: + name: readme + options: + tabulate_vars: False + +renderer: + autotrim: True + include_header: "docs/.header.md" + force_overwrite: True diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 17b060f26bd99bfbec2ffbe6fbb0adf4ddc1055f..5e8c7bf435c486bb7901fd8d44bfd3368c20731e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,14 +6,16 @@ include: - "templates/check-secrets-project.yml" - "templates/docker-clean-garbage.yml" - "templates/ansible-test-role.yml" - - "templates/gitea-post-actions.yml" - ref: "development" + - "templates/gitlab-pullrequest-open.yml" + - "templates/gitlab-pullrequest-closed.yml" + ref: "1.4.0" variables: BOOK_TYPE: "role" PACKAGE_MANAGER: "apt,yum" PLATFORM_SUPPORTED: "amd64,arm64" - GITEA_REPOSITORY: "https://gitea.services.arroyof.com/Ansible_Roles/deployer" + # GITEA_REPOSITORY: "https://gitea.services.arroyof.com/Ansible_Roles/aptman" + GITLAB_REPOSITORY: "https://gitlab.com/ansible-roles9/deployer" stages: - get-scripts @@ -21,46 +23,97 @@ stages: - analyze-secrets - docker-clean-garbage - test-ansible-role - - gitea-jobs + - autodoc-task + - gitlab-jobs + +download_scripts: + extends: .get_scripts + stage: get-scripts + variables: + LIBRARIES_VERSION: "1.4.0" syntax_check: - dependencies: - - get_scripts + extends: .syntax_check + stage: syntax-check variables: CODELINTER_PATHS: "/tasks/,/tests/" + CODELINTER_TYPE: "yamllint" + dependencies: + - download_scripts check_secrets: + extends: .check_secrets + stage: analyze-secrets + dependencies: + - download_scripts + +check_trivy_secrets: + extends: .trivy_secrets + stage: analyze-secrets dependencies: - - get_scripts + - download_scripts clean_containers_amd64: + extends: .clean_containers_amd64 + stage: docker-clean-garbage dependencies: - - get_scripts + - download_scripts clean_containers_arm64: + extends: .clean_containers_arm64 + stage: docker-clean-garbage dependencies: - - get_scripts + - download_scripts ansible_role_yum_amd64: + extends: .ansible_role_yum_amd64 + stage: test-ansible-role dependencies: - - get_scripts + - download_scripts ansible_role_yum_arm64: + extends: .ansible_role_yum_arm64 + stage: test-ansible-role dependencies: - - get_scripts + - download_scripts ansible_role_apt_amd64: + extends: .ansible_role_apt_amd64 + stage: test-ansible-role dependencies: - - get_scripts + - download_scripts ansible_role_apt_arm64: + extends: .ansible_role_apt_arm64 + stage: test-ansible-role dependencies: - - get_scripts + - download_scripts -tag_project: +auto_doc: + extends: .autodoc_project + stage: autodoc-task + variables: + DOC_LANGUAGE: "ansible" dependencies: - - get_scripts + - download_scripts -pr_project: +pull_request: + extends: .pr_project + stage: gitlab-jobs dependencies: - - get_scripts + - download_scripts + +tagging: + extends: .tag_project + stage: gitlab-jobs + dependencies: + - download_scripts + +# backing_up: +# extends: .backup_project +# stage: gitlab-jobs +# dependencies: +# - download_scripts +# needs: +# - tagging +# - download_scripts diff --git a/CHANGELOG.md b/CHANGELOG.md index a78ebac41cb0c8a48565d2da6a1c137c0cfd9bde..7b43d56443078c2e8679e2aa54c3574761441b45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# [1.4.0](/Ansible_Roles/deployer/compare/1.4.0...master) +* Change the `gitlab-ci.yml` version according the new cicd behavior (now the main SCM will be Gitlab) +* Adding configuration for *ansible-doctor* +* Improvements over the code comments in order to be able use by `ansible-doctor` utility + # [1.3.0](/Ansible_Roles/deployer/compare/1.3.0...master) * CICD migraton from Jenkins to GitlabCI diff --git a/README.md b/README.md index 19c55e7d155a3a17442c566446d9f9f0d769fdd8..f733884c9c2b4a7b37c724e15f1b1e708998de1b 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,160 @@ -[![pipeline status](https://gitlab.com/ansible-roles9/deployer/badges/development/pipeline.svg)](https://gitlab.com/ansible-roles9/deployer/-/commits/development) ![Project version](https://img.shields.io/gitlab/v/tag/ansible-roles9/deployer)![Project license](https://img.shields.io/gitlab/license/ansible-roles9/deployer) +[![pipeline status](https://gitlab.com/ansible-roles9/deployer/badges/development/pipeline.svg)](https://gitlab.com/ansible-roles9/deployer/-/commits/development) ![Project version](https://img.shields.io/gitlab/v/tag/ansible-roles9/deployer)! [Project license](https://img.shields.io/gitlab/license/ansible-roles9/deployer) -Role DEPLOYER -=================== +## How to use -Description -------------- -This roles allow to deploy **GIT projects** to managed servers, its can content *scripts* or *regular files*. - -Requirements -------------- -This role do not have special requirements from another roles. - -How to use -------------- -``` +```yaml - import_role: name: deployer vars: project_details: - - {destination: "/tools/script/proyecto/", repository: "https://gitlab.com/docker-files1/vsftpd.git", owner: "mimo", group: "losmimos", script: true} - - {destination: "/tools/script/proyecto1/", repository: "https://gitlab.com/shell-snippets/cleanKernel.git", script: true} - - {destination: "/tools/script/proyecto2/", repository: "https://gitlab.com/docker-files1/gitlab-runner.git", script: false, version: "1.0.2"} + - destination: "/tools/script/proyecto/" + repository: "https://gitlab.com/docker-files1/vsftpd.git" + owner: "mimo" + group: "losmimos" + script: true + - destination: "/tools/script/proyecto2/" + repository: "https://gitlab.com/docker-files1/vsftpd.git" + script: false + version: "1.7.1" + - destination: "/tools/script/proyecto3/" + repository: "https://gitlab.com/shell-snippets/cleanKernel.git" + script: true + version: "main" ``` -Before that, you need to set with a valid ***Gitlab token*** the variable `gitlab_cicd_token` on **defaults/main.yml** otherwise, the project fetching will fail. +A role to deploy software over servers -Variables root -------------- +## Table of content -* Variable name: `gitlab_cicd_token` -* Variable level: root -* Default value: empty. -* Accepted values: String. -* Description: *Git* token that will be used to fetch private projects. +- [Requirements](#requirements) +- [Default Variables](#default-variables) + - [deploy_custom_base_directory](#deploy_custom_base_directory) + - [deploy_custom_directory](#deploy_custom_directory) + - [exec_patterns](#exec_patterns) + - [gitlab_cicd_token](#gitlab_cicd_token) + - [project_details](#project_details) + - [requiredpackages](#requiredpackages) + - [without_output](#without_output) +- [Dependencies](#dependencies) +- [License](#license) +- [Author](#author) ----------- +--- -* Variable name: `project_details` -* Variable level: root -* Default value: empty []. -* Accepted values: Dictonary key => value. -* Description: Dictionary keys with the configuration that will be used for each software delivery. +## Requirements -Variables child `project_details` -------------- +- Minimum Ansible version: `2.8.5` -* Variable name: `destination` -* Default value: empty. -* Accepted values: String [ KS ] -* Description: The path on the destination server where the *Git* project files will be located. +## Default Variables ----------- +### deploy_custom_base_directory -* Variable name: `repository` -* Default value: empty. -* Accepted values: URL [ KS ] -* Description: Source *Git* repository where the file are alocated. +Variable that contains the deployment custom base directory path. ----------- +**_Type:_** string
+ +#### Default value + +```YAML +deploy_custom_base_directory: /etc/custom/ +``` -* Variable name: `owner` -* Default value: empty. -* Accepted values: String [ KS ] -* Description: The *owner* that the deployed files will be assigned. +### deploy_custom_directory + +Variable that contains the deployment custom directory path. + +**_Type:_** string
+ +#### Default value + +```YAML +deploy_custom_directory: /etc/custom/deployer/ +``` + +### exec_patterns + +Variable that contains the executables patterns. + +**_Type:_** string
+ +#### Default value + +```YAML +exec_patterns: '*.sh,*.py,*.pl' +``` + +### gitlab_cicd_token + +#### Default value + +```YAML +gitlab_cicd_token: ESTE_VALOR_PROVOCA_UN_FALLO_DE_AUTENTICACION +``` + +### project_details + +Variable intended to contain the list of project_details for the purposes of each deployment. + +**_Type:_** list
+ +#### Default value + +```YAML +project_details: [] +``` + +#### Example usage + +```YAML +project_details: + - destination: /foo + repository: url{.git} + script: true} + - destination: /foo2 + repository: url{.git} + version: 1.3.4 + owner: user + group: group +``` + +### requiredpackages + +Variable that contains the Packages that will be installed over base system. + +**_Type:_** list
+ +#### Default value + +```YAML +requiredpackages: + - rsync + - wget + - unzip + - git +``` + +### without_output + +Variable that contains a bool to decide if want output or not. + +**_Type:_** bool
+ +#### Default value + +```YAML +without_output: true +``` ----------- -* Variable name: `group` -* Default value: empty. -* Accepted values: String [ KS ] -* Description: The *group* that the deployed files will be assigned. ----------- +## Dependencies -* Variable name: `script` -* Default value: empty. -* Accepted values: Boleano. -* Description: **true** to assign execution permissions to file scripts [ **.sh|.py|.pl** ] +None. ----------- +## License -* Variable name: `version` -* Default value: master. -* Accepted values: String [ KS ]. -* Description: The *Git* project version that you want to clone on the destination server. +GPLv3 -Singularities -------------- -In order to still over the Linux standard, for each project that be deployed using this role, will be create with the same name on, [/etc/custom/deployer/], it can be used for don't static configurations, this directory is not managed by the role. +## Author -Legend -------------- -* NKS => No key sensitive -* KS => Key sensitive +Enzo Arroyo diff --git a/docs/.header.md b/docs/.header.md new file mode 100644 index 0000000000000000000000000000000000000000..1b4799130968fd6929d565d29b8512c647897c81 --- /dev/null +++ b/docs/.header.md @@ -0,0 +1,23 @@ +[![pipeline status](https://gitlab.com/ansible-roles9/deployer/badges/development/pipeline.svg)](https://gitlab.com/ansible-roles9/deployer/-/commits/development) ![Project version](https://img.shields.io/gitlab/v/tag/ansible-roles9/deployer)! [Project license](https://img.shields.io/gitlab/license/ansible-roles9/deployer) + +## How to use + +```yaml +- import_role: + name: deployer + vars: + project_details: + - destination: "/tools/script/proyecto/" + repository: "https://gitlab.com/docker-files1/vsftpd.git" + owner: "mimo" + group: "losmimos" + script: true + - destination: "/tools/script/proyecto2/" + repository: "https://gitlab.com/docker-files1/vsftpd.git" + script: false + version: "1.7.1" + - destination: "/tools/script/proyecto3/" + repository: "https://gitlab.com/shell-snippets/cleanKernel.git" + script: true + version: "main" +``` diff --git a/meta/main.yml b/meta/main.yml index eb0186fda0c6dbeb8be228b4457454e65039a2e2..d157771e02d61317c0cb0b7f8268728f3657d7d7 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,4 +23,5 @@ galaxy_info: - name: Ubuntu versions: - 20 + - 22.04 ... diff --git a/vars/main.yml b/vars/main.yml index 361029ca93f0b8352e337ece8b4c911d2a3681c5..b71a1e5ca69d0e49f62d48d00a4373be9133bb6f 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,13 +1,42 @@ --- # vars file for deployer role +# @var requiredpackages:value: $ ["rsync", "wget", "unzip", "git"] +# @var requiredpackages:description: Variable that contains the Packages that will be installed over base system. +# @var requiredpackages:type: list requiredpackages: - rsync - wget - unzip - git +# @var project_details:value: $ [] +# @var project_details:description: Variable intended to contain the list of project_details for the purposes of each deployment. +# @var project_details:type: list +# @var project_details:example: > +# project_details: +# - destination: /foo +# repository: url{.git} +# script: true} +# - destination: /foo2 +# repository: url{.git} +# version: 1.3.4 +# owner: user +# group: group +# @end project_details: [] +# @var deploy_custom_base_directory:value: $ "/etc/custom/" +# @var deploy_custom_base_directory:description: Variable that contains the deployment custom base directory path. +# @var deploy_custom_base_directory:type: string deploy_custom_base_directory: "/etc/custom/" +# @var deploy_custom_directory:value: $ "/etc/custom/deployer/" +# @var deploy_custom_directory:description: Variable that contains the deployment custom directory path. +# @var deploy_custom_directory:type: string deploy_custom_directory: "{{ deploy_custom_base_directory }}{{ role_name }}/" +# @var exec_patterns:value: $ "*.sh,*.py,*.pl" +# @var exec_patterns:description: Variable that contains the executables patterns. +# @var exec_patterns:type: string exec_patterns: "*.sh,*.py,*.pl" +# @var without_output:value: $ true +# @var without_output:description: Variable that contains a bool to decide if want output or not. +# @var without_output:type: bool without_output: true ...