diff --git a/concourse/concourse.txt b/concourse/concourse.txt new file mode 100644 index 0000000..4b0267d --- /dev/null +++ b/concourse/concourse.txt @@ -0,0 +1,19 @@ +Concourse +------------- + +- install concourse avec docker-compose +- install de fly + +tunel ssh pour pouvoir accéder à l'appli web + +ssh -L 8080:localhost:8080 ubuntu@mistergwen.site + +fly -t tutorial login -c http://localhost:8080 -u test -p test + +fly -t tutorial set-pipeline -p hello-world -c hello-world.yml +fly -t tutorial unpause-pipeline -p hello-world +fly -t tutorial trigger-job --job hello-world/hello-world-job --watch + +pour nettoyer : +fly -t tutorial destroy-pipeline -p hello-world + diff --git a/concourse/concourse_target.md b/concourse/concourse_target.md new file mode 100644 index 0000000..32c50fd --- /dev/null +++ b/concourse/concourse_target.md @@ -0,0 +1,40 @@ +Dans le contexte d'un pipeline **Concourse**, une **target** fait généralement référence à un **environnement de déploiement** ou à un **ensemble d'objectifs (targets)** où un job doit être exécuté. Cela fait partie de la configuration permettant de déterminer où les ressources et les jobs doivent être déployés ou exécutés, que ce soit sur un environnement local ou distant. + +### Définition et utilisation de "target" dans un pipeline Concourse : +1. **Environnement d'exécution** : + - Une target représente l'endroit où les actions de pipeline (telles que les jobs ou les ressources) seront exécutées. Ce peut être un serveur de déploiement, un environnement de tests, ou une machine virtuelle dans le cas de Concourse. Chaque instance de Concourse peut être configurée pour interagir avec des environnements différents ou des ressources externes à travers des "targets". + +2. **Dans les ressources et les actions** : + - Dans un pipeline Concourse, des ressources (comme les dépôts Git, les images Docker, ou les artefacts) peuvent être connectées à des targets, ce qui indique à Concourse de quelle manière et où interagir avec ces ressources. + - Exemple : si vous avez une ressource qui interagit avec un service externe comme AWS, une cible peut être utilisée pour configurer l'authentification et l'interaction avec cet environnement. + +3. **Dans la configuration de Concourse** : + - Concourse utilise des "targets" dans sa configuration pour déterminer les paramètres relatifs aux connexions aux systèmes externes. Les **targets** sont utilisés dans des fichiers de configuration ou de pipeline pour établir des connexions aux environnements de déploiement ou aux systèmes tiers. Par exemple, cela pourrait concerner des environnements comme `production`, `staging` ou `dev`. + +### Exemple pratique : +Disons que vous avez un pipeline qui déploie une application sur plusieurs environnements, par exemple : +- Un environnement de développement (dev). +- Un environnement de staging. +- Un environnement de production. + +Chaque environnement aurait une **target** associée. Par exemple : +```yaml +resources: + - name: git-repo + type: git + source: + uri: "https://github.com/monrepo" + branch: master + target: staging # Ici la target désignerait l'environnement "staging" pour ce job + +jobs: + - name: deploy-dev + plan: + - get: git-repo + trigger: true + - task: deploy-to-dev + target: dev # Ici la target désignerait l'environnement "dev" +``` + +### Conclusion : +En résumé, une **target** dans un pipeline **Concourse** est un mécanisme pour spécifier où les ressources doivent être utilisées ou où les actions doivent être exécutées. C'est une abstraction pour interagir avec différents environnements ou systèmes externes en fonction du contexte de votre pipeline. Cela permet d'avoir un contrôle fin sur le déploiement, l'exécution des tâches, et l'intégration avec d'autres outils ou plateformes. diff --git a/concourse/connector.yaml b/concourse/connector.yaml new file mode 100644 index 0000000..6d97851 --- /dev/null +++ b/concourse/connector.yaml @@ -0,0 +1,25 @@ +resources: + - name: exo_resource + type: git + source: + uri: https://forge.gwenaelremond.fr/gwen/larochellemaalsi2023/ + branch: develop + + +jobs: + - name: job-resource + plan: + - get: exo_resource + trigger: true + - task: diff + config: + inputs: + - name: exo_resource + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + run: + path: echo + args: ["Test"] diff --git a/concourse/docker-compose.yml b/concourse/docker-compose.yml new file mode 100644 index 0000000..e6ba778 --- /dev/null +++ b/concourse/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3' + +services: + concourse-db: + image: postgres + environment: + POSTGRES_DB: concourse + POSTGRES_PASSWORD: concourse_pass + POSTGRES_USER: concourse_user + PGDATA: /database + + concourse: + image: concourse/concourse + command: quickstart + privileged: true + depends_on: [concourse-db] + ports: ["8080:8080"] + environment: + CONCOURSE_POSTGRES_HOST: concourse-db + CONCOURSE_POSTGRES_USER: concourse_user + CONCOURSE_POSTGRES_PASSWORD: concourse_pass + CONCOURSE_POSTGRES_DATABASE: concourse + CONCOURSE_EXTERNAL_URL: http://localhost:8080 + CONCOURSE_ADD_LOCAL_USER: test:test + CONCOURSE_MAIN_TEAM_LOCAL_USER: test + # instead of relying on the default "detect" + CONCOURSE_WORKER_BAGGAGECLAIM_DRIVER: overlay + CONCOURSE_CLIENT_SECRET: Y29uY291cnNlLXdlYgo= + CONCOURSE_TSA_CLIENT_SECRET: Y29uY291cnNlLXdvcmtlcgo= + CONCOURSE_X_FRAME_OPTIONS: allow + CONCOURSE_CONTENT_SECURITY_POLICY: "*" + CONCOURSE_CLUSTER_NAME: tutorial + CONCOURSE_WORKER_CONTAINERD_DNS_SERVER: "8.8.8.8" + # For ARM-based machine, change the Concourse runtime to "houdini" + CONCOURSE_WORKER_RUNTIME: "containerd" diff --git a/concourse/exo2.yml b/concourse/exo2.yml new file mode 100644 index 0000000..c10d011 --- /dev/null +++ b/concourse/exo2.yml @@ -0,0 +1,15 @@ +jobs: +- name: hello-world-job + plan: + - task: hello-world-task + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + outputs: + - name: the-artifact + run: + path: ls + args: ["-lF"] diff --git a/concourse/exo3.yml b/concourse/exo3.yml new file mode 100644 index 0000000..42e5c61 --- /dev/null +++ b/concourse/exo3.yml @@ -0,0 +1,36 @@ +jobs: +- name: hello-world-job + plan: + - task: hello-world-task + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + outputs: + - name: the-artifact + run: + path: sh + args: + - -cx + - | + ls -l . + echo "hello from another step!" > the-artifact/message + - task: read-the-artifact + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + # To receive "the-artifact", specify it as an input + inputs: + - name: the-artifact + run: + path: sh + args: + - -cx + - | + ls -l . + cat the-artifact/message diff --git a/concourse/exo_resource.yml b/concourse/exo_resource.yml new file mode 100644 index 0000000..ada09b3 --- /dev/null +++ b/concourse/exo_resource.yml @@ -0,0 +1,26 @@ +--- +resources: +- name: exo_resource + type: git + source: + uri: https://forge.gwenaelremond.fr/gwen/chateauroux/ + branch: develop + + +jobs: +- name: job-resource + plan: + - get: exo_resource + trigger: true + - task: diff + config: + inputs: + - name: exo_resource + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + run: + path: echo + args: ["Test"] diff --git a/concourse/from_resource/hello.yml b/concourse/from_resource/hello.yml new file mode 100644 index 0000000..9700438 --- /dev/null +++ b/concourse/from_resource/hello.yml @@ -0,0 +1,10 @@ +- task: hello + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + run: + path: echo + args: ["Hello world!"] diff --git a/concourse/from_resource/hello_from_resource.yml b/concourse/from_resource/hello_from_resource.yml new file mode 100644 index 0000000..7d65b87 --- /dev/null +++ b/concourse/from_resource/hello_from_resource.yml @@ -0,0 +1,16 @@ +resources: + - name: ci + type: git + source: + uri: https://forge.gwenaelremond.fr/gwen/chateauroux + branch: main + version: + ref: 8e78227300e4dcd88d7b85a84a15f4a0fc5ece8f + +jobs: +- name: time-job + public: true + plan: + - get: ci + - task: hello + file: hello.yml diff --git a/concourse/hello-world.yml b/concourse/hello-world.yml new file mode 100644 index 0000000..401a4df --- /dev/null +++ b/concourse/hello-world.yml @@ -0,0 +1,13 @@ +jobs: +- name: hello-world-job + plan: + - task: hello-world-task + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + run: + path: echo + args: ["Hello world!"] diff --git a/concourse/hello-world.yml.1 b/concourse/hello-world.yml.1 new file mode 100644 index 0000000..8d165ed --- /dev/null +++ b/concourse/hello-world.yml.1 @@ -0,0 +1,25 @@ +jobs: +- name: hello-world-job + plan: + - task: hello-world-task + config: + # Tells Concourse which type of worker this task should run on + platform: linux + # This is one way of telling Concourse which container image to use for a + # task. We'll explain this more when talking about resources + image_resource: + type: registry-image + source: + repository: busybox # images are pulled from docker hub by default + # The command Concourse will run inside the container + # echo "Hello world!" +# run: +# path: echo +# args: ["Hello world!"] + outputs: + - name: the-artifact + run: + # Change the command to `ls -lF` to see + # what the task sees in its working directory + path: ls + args: ["-lF"] diff --git a/concourse/hello-world.yml.2 b/concourse/hello-world.yml.2 new file mode 100644 index 0000000..940181d --- /dev/null +++ b/concourse/hello-world.yml.2 @@ -0,0 +1,39 @@ +jobs: +- name: hello-world-job + plan: + - task: hello-world-task + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + outputs: + - name: the-artifact + run: + # This is a neat way of embedding a script into a task + path: sh + args: + - -cx + - | + ls -l . + echo "hello from another step!" > the-artifact/message + # Add a second task that reads the contents of the-artifact/message + - task: read-the-artifact + config: + platform: linux + image_resource: + type: registry-image + source: + repository: busybox + # To receive "the-artifact", specify it as an input + inputs: + - name: the-artifact + run: + path: sh + args: + - -cx + - | + ls -l . + cat the-artifact/message + cp -a the-artifact /tmp/ diff --git a/concourse/last.yml b/concourse/last.yml new file mode 100644 index 0000000..1b94a8f --- /dev/null +++ b/concourse/last.yml @@ -0,0 +1,15 @@ +--- +resources: + - name: resource-tutorial + type: git + source: + uri: https://github.com/starkandwayne/concourse-tutorial.git + branch: develop + +jobs: + - name: job-hello-world + public: true + plan: + - get: resource-tutorial + - task: hello-world + file: resource-tutorial/tutorials/basic/task-hello-world/task_hello_world.yml diff --git a/concourse/standalone_task.yml b/concourse/standalone_task.yml new file mode 100644 index 0000000..cd68f67 --- /dev/null +++ b/concourse/standalone_task.yml @@ -0,0 +1,14 @@ +#to be lauched with the -i arg +#fly -t tutorial execute -c manual_launch.yml -i manual=. +platform: linux +image_resource: + type: registry-image + source: + repository: alpine/ansible +inputs: + - name: manual +run: + args: + - manual/print_hello.yml + path: ansible-playbook +