{"id":20389306,"url":"https://github.com/positiondev/tni-wordpress","last_synced_at":"2025-03-04T23:44:43.812Z","repository":{"id":142264435,"uuid":"77698079","full_name":"positiondev/tni-wordpress","owner":"positiondev","description":"With Bedrock and Trellis","archived":false,"fork":false,"pushed_at":"2017-10-10T19:46:08.000Z","size":635,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-15T10:02:32.715Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/positiondev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-30T16:38:35.000Z","updated_at":"2017-01-27T22:54:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"82a4d657-9b1a-40ee-8874-63c87d3571e4","html_url":"https://github.com/positiondev/tni-wordpress","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positiondev%2Ftni-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positiondev%2Ftni-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positiondev%2Ftni-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positiondev%2Ftni-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/positiondev","download_url":"https://codeload.github.com/positiondev/tni-wordpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940539,"owners_count":20045878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T03:17:15.655Z","updated_at":"2025-03-04T23:44:43.803Z","avatar_url":"https://github.com/positiondev.png","language":"Python","readme":"# How to use\n\n## Setup\n\nCreate `thenewinquiry.com` directory\n\n`mkdir thenewinquiry.com`\n\nInside newly-created `thenewinquiry.com` directory: `git clone git@github.com:positiondev/tni-wordpress.git`\n\nor `mkdir thenewinquiry.com \u0026\u0026 cd thenewinquiry.com \u0026\u0026 git clone git@github.com:positiondev/tni-wordpress.git`\n\nGet the vault password from somebody.\n\nCreate a `.vault_pass` file in the `trellis` directory and put only the Vault password in it (it's not YAML formatted, the only thing in the file should be the vault password).\n\nMake sure somebody has added your public key to the server.\n\nInstall Ansible Configuration for deployment\n\nInside the `trellis` directory: `ansible-galaxy install -r requirements.yml`\n\n## Development\n\n`site/config/environments/development.php` is gitignored so your can develop this site using VV instead of Trellis if needed.\n\nAdd to `site/config/environments/development.php`:\n\n```\n\u003c?php\n/** Development */\ndefine('SAVEQUERIES', true);\ndefine('WP_DEBUG', true);\ndefine('SCRIPT_DEBUG', true);\n```\n\nref: https://codex.wordpress.org/WP_DEBUG\n\n`cd trellis` and run `vagrant up`.\n\nThe `site` directory contains the actual WordPress files. Change `composer.json` to add plugins, themes, etc. Run `composer update` and commit `composer.lock` before attempting to deploy. You don't need to commit anything in the `themes` directory.\n\nDon't manually edit anything on the server. When things are changed manually, then the updates through Ansible don't work anymore. Make server changes only through Trellis/Ansible. This ensures reproducibility of builds, correct permissions, etc.\n\n## Deployment\n\nRun `ansible-playbook server.yml -e env=staging` (only if you make changes to the server in `trellis`).\n\nWithin the `trellis` directory run `./bin/deploy.sh {environement} thenewinquiry.com` to deploy `site` changes (where `{environment}` is `staging` or `production`)\n\nIf you run into permissions problems with cloning the git repo, try the following:\n\n- run `ssh-agent`: eval `ssh-agent -s`\n- add your key to the agent: `ssh-add ~/.ssh/id_rsa`\n- check that your key was added: `ssh-add -L`\n\nWhen updating the plugin or theme, update the version numbers in `site/composer.json` (for each there are two locations to update the version).\n\nFor whatever reason, Trellis doesn't run `composer update`...we can add this into the playbook eventually but for now after deploying, ssh into the server and cd into `/srv/www/thenewinquiry.com/current` and run `composer update`.\n\n### Code Changes\n\n* In order to deploy changes to the theme or to update a plugin (including the core functionality plugin), the composer.json file needs to be updated.\n\n#### Custom\n\nThe theme and our core functionality plugin need to be assigned a new version number (with tag in git) and that version needs to be added to the composer.json file in the `site` directory.\n\nChanges are needed in the following:\n\n`repositories` section of `composer.json`\n\n```json\n\"version\": \"0.5.0\",\n```\n\n`require` section of `composer.json`\n\n```json\n\"thenewinquiry/tni\": \"^0.5.0\"\n```\n\nTo add or remove plugins, they should be added to the `require` section of the `composer.json` file. If the plugin is in the WordPress repository, the plugin can be added from [WPackagist](https://wpackagist.org/).\n\n# How I did this\n\nThis is not a how-to, just notes. Nobody should have to do this stuff for TNI again.\n\n## EC2 and CloudFlare\n\n  - Made EC2 instance\n    - Ubuntu 16.04\n    - Micro/free tier\n    - Security groups:\n    - Use launch wizard SSH security group\n    - Also add security group for incoming HTTP and HTTPS\n    - Create new keys\n  - Create a CNAME on CloudFlare.\n  - Add new sub-domain and keys to .ssh/config:\n```\nHost new-staging.positiondevapp.com\n  ForwardAgent yes\n  IdentityFile ~/.ssh/aws-new.pem\n```\n  - Import SSH key password into Keychain by running `ssh-add -K`.\n\n## Cloning/Forking Roots\n\nI originally tried to do this in a way that would keep the trellis and bedrock in separate repos, but this does *not* seem to be the way that Roots is intended to be used. Instead, we're going to keep them in the same repo. If we want to update trellis or bedrock later, only the files mentioned in the \"Staging\" and \"Development\" sections have changed.\n\n - Create local site directory\n - Inside directory, `git clone --depth=1 git@github.com:positiondev/position-trellis.git \u0026\u0026 rm -rf trellis/.git`\n - Inside directory, `git clone --depth=1 git@github.com:roots/bedrock.git site \u0026\u0026 rm -rf site/.git`\n - `git init`, create Github repo for the tni-wordpress repo\n\n## Development\n\n - Change `group_vars/development/wordpress_sites.yml` to correct site name, dev host names\n - Change `group_vars/development/vault.yml` to correct site name\n - Run `vagrant up`\n\n## Staging\n - Change `group_vars/all/users.yml`\n   - Key lookup: `\"{{ lookup('file', '~/.ssh/aws-new.pub') }}\"`\n   - Add `admin_user: ubuntu`\n - Change `group_vars/staging/wordpress_sites.yml`\n   - Change the site name\n   - Enter location of Bedrock repo\n   - Remove `repo_subtree_path `\n - Change `group_vars/staging/vault.yml`\n   - Generate passwords and salts\n - Change `hosts/staging`\n   - Add actual hostnames to `[web]` and `[staging]`\n - Change `roles/remote-user/tasks/main.yml`\n   - We removed the check for whether Ansible was able to connect as root (since we know it can’t)\n - Change `server.yml` to `apt-get update` before installing python.\n - Run `ansible-playbook server.yml -e env=staging`\n - Run `./bin/deploy.sh staging thenewinquiry.com`\n\n## Before committing, secure the passwords\n\n - Create `.vault_pass` and put a strong password in it\n - Copy `.vault_pass` to meta\n - Add `vault_password_file = .vault_pass` to `ansible.cfg`\n - Use `ansible-vault` to encrypt the vault files\n\n# What's left\n\n - How to share SSH keys\n - SSL (Trellis has built-in let’s encrypt, so should be straightforward)\n\n## SSH keys idea\n\n - Collect every contributor’s public keys in `.ssh`\n - Add those keys to the list for `{{ admin_user }}` in `users.yml`\n - Only the first person to set up the server needs the original AWS key\n - Other contributors will refer to their own private key in `.ssh/config` instead of the original AWS key\n - Drawback: everybody needs everyone else’s public keys? I think? (this is not so bad imho)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpositiondev%2Ftni-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpositiondev%2Ftni-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpositiondev%2Ftni-wordpress/lists"}