runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.82k stars 1.06k forks source link

Define workflow without steps for plan and apply #2740

Closed lvthao closed 4 days ago

lvthao commented 1 year ago

I have setup multiple atlantis server to run for each atlantis workflow. I used document here https://www.runatlantis.io/docs/server-side-repo-config.html My atlantis.yaml file look like

version: 3
projects:
- name: custom1
  dir: .
  workspace: custom1
  workflow: custom1
- name: custom2
  dir: .
  workspace: custom2
  workflow: custom2
...

my repo server side config repos.yaml on atlantis server

      allowed_overrides: ["workflow"]
      allow_custom_workflows: true
      allowed_workflows: [custom1,custom2]
    workflows:
      custom1:
        plan:
          steps:
          - run: rm -rf .terraform 
          - init:
              extra_args: ["-backend-config=abc.backend", "-upgrade=false"]
          - plan:
              extra_args: [-var-file=custom1.tfvars]
      custom2: # i want to do nothing on the custom2 workflow. this config create a lock and return empty line message 
        plan:
            steps: []
        apply:
          steps: [] 

As i understand if we define the workflow on the atlantis.yaml we need to define a workflow action on server side repo config.

Do we have any way to define custom2 workflow but we don't run any plan or apply on this workflow.

jamengual commented 1 year ago

I think you can do a run step in plan with an touch $PLANFILE and it should work.

On Wed, Nov 30, 2022, 2:15 a.m. ThaoLuong @.***> wrote:

I have setup multiple atlantis server to run for each atlantis workflow. I used document here https://www.runatlantis.io/docs/server-side-repo-config.html My atlantis.yaml file look like

version: 3 projects:

  • name: custom1 dir: . workspace: custom1 workflow: custom1
  • name: custom2 dir: . workspace: custom2 workflow: custom2 ...

my repo server side config repos.yaml on atlantis server

  allowed_overrides: ["workflow"]
  allow_custom_workflows: true
  allowed_workflows: [custom1,custom2]
workflows:
  custom1:
    plan:
      steps:
      - run: rm -rf .terraform
      - init:
          extra_args: ["-backend-config=abc.backend", "-upgrade=false"]
      - plan:
          extra_args: [-var-file=custom1.tfvars]
  custom2: # i want to do nothing on the custom2 workflow. this config create a lock and return empty line message
    plan:
        steps: []
    apply:
      steps: []

As i understand if we define the workflow on the atlantis.yaml we need to define a workflow action on server side repo config.

Do we have any way to define custom2 workflow but we don't run any plan or apply on this workflow.

— Reply to this email directly, view it on GitHub https://github.com/runatlantis/atlantis/issues/2740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERD5B3MFH7IJJ4IFAS3WK4SK7ANCNFSM6AAAAAASPOPLEY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

lvthao commented 1 year ago

It still run the plan and create a lock file and return empty line like that image

jamengual commented 1 year ago

what if you run the command only without the plan file?

On Wed, Nov 30, 2022 at 6:58 PM ThaoLuong @.***> wrote:

It still run the plan and create a lock file and return empty line like that [image: image] https://user-images.githubusercontent.com/7249525/204955532-241684ec-ef35-4b58-8706-5dc47961e018.png

— Reply to this email directly, view it on GitHub https://github.com/runatlantis/atlantis/issues/2740#issuecomment-1333087366, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERELEFZ5SRTEHHEFBETWLAH4PANCNFSM6AAAAAASPOPLEY . You are receiving this because you commented.Message ID: @.***>

jamengual commented 1 year ago

https://github.com/runatlantis/atlantis/issues/2498

lvthao commented 1 year ago

add plan like that

        plan:
          steps:
          - run : touch 

and get error about missing operand for touch


touch: missing file operand
Try 'touch --help' for more information. ```
nitrocode commented 1 year ago

@lvthao what problem are you trying to solve with a workflow with an empty plan/apply?